← Todos los ejemplos
Ejemplo 23
Charts by symbol
a report of the workspace by symbol — how many charts each
- Categoría
- Espacio de trabajo: lee o cambia gráficos y paneles
- Permisos
- workspace.read
- Antes de ejecutarlo
- a terminal window
- Qué hace
- none
- 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: a report of the workspace by symbol — how many charts each // symbol has and at which timeframes — and of the panels that are not // charts. Changes nothing. // Category: workspace // Permissions: workspace.read // Preconditions: a terminal window // Side effects: none // Run: in TTT, open the T0 Editor, open this file, grant workspace.read, // Run. lang ">=0.1.1, <0.2.0"; host "ttt" ">=0.1.1, <0.2.0"; requires "workspace" ">=0.1.1, <0.2.0"; import std.list; fn main() { let mut seen: List<String> = []; for c in workspace.charts() { if !list.contains(seen, c.symbol) { seen.push(c.symbol); } } for symbol in seen { let mut timeframes: List<String> = []; for c in workspace.charts() { if c.symbol == symbol { timeframes.push(c.timeframe); } } print(symbol + ": " + to_string(timeframes.len()) + " chart(s) " + to_string(timeframes)); } let mut others = 0; for p in workspace.panels() { if p.kind != "Chart" { others = others + 1; print("panel: " + p.title); } } print(to_string(others) + " panel(s) besides the charts"); }