← 모든 예제
예제 20
All charts to timeframe
put every open chart on one timeframe, and say which ones
- 분류
- Workspace: 차트와 패널을 읽거나 변경
- 권한
- workspace.readworkspace.write
- 실행하기 전에
- a terminal window
- 하는 일
- CHANGES YOUR WORKSPACE — sets the timeframe of every open
- 실행 방법
- in TTT, open the T0 Editor, open this file, grant workspace.read
- 언어
>=0.1.1, <0.2.0- 호스트
>=0.1.1, <0.2.0- 필요한 것
- workspace >=0.1.1, <0.2.0
소스
// Purpose: put every open chart on one timeframe, and say which ones // were already there. A refused timeframe stops the program before it // touches a chart. // Category: workspace // Permissions: workspace.read, workspace.write // Preconditions: a terminal window // Side effects: CHANGES YOUR WORKSPACE — sets the timeframe of every open // chart. // Run: in TTT, open the T0 Editor, open this file, grant workspace.read // and workspace.write, Run. Change `timeframe` (5m, 1h, 1D ...). lang ">=0.1.1, <0.2.0"; host "ttt" ">=0.1.1, <0.2.0"; requires "workspace" ">=0.1.1, <0.2.0"; fn main() -> Result<Unit, Error> { let timeframe = "15m"; let mut changed = 0; for c in workspace.charts() { if c.timeframe == timeframe { print(c.symbol + ": already " + timeframe); } else { workspace.set_timeframe(c.chart, timeframe)?; changed = changed + 1; print(c.symbol + ": " + c.timeframe + " -> " + timeframe); } } print(to_string(changed) + " chart(s) changed"); return Ok(()); }