← Todos los ejemplos
Ejemplo 20
All charts to timeframe
put every open chart on one timeframe, and say which ones
- Categoría
- Espacio de trabajo: lee o cambia gráficos y paneles
- Permisos
- workspace.readworkspace.write
- Antes de ejecutarlo
- a terminal window
- Qué hace
- CHANGES YOUR WORKSPACE — sets the timeframe of every open
- Cómo ejecutarlo
- in TTT, open the T0 Editor, open this file, grant workspace.read
- Lenguaje
>=0.1.1, <0.2.0- Host
>=0.1.1, <0.2.0- Necesita
- workspace >=0.1.1, <0.2.0
Código
// 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(()); }