← すべてのサンプル
サンプル 22
Focus or open
bring a symbol's chart to the front, opening one if there is
- カテゴリ
- Workspace:チャートやパネルを読む・変更する
- 権限
- workspace.readworkspace.write
- 実行する前に
- a terminal window; the symbol offered by the terminal
- 何をするか
- CHANGES YOUR WORKSPACE — focuses a chart, or opens one (at
- 実行方法
- in TTT, open the T0 Editor, open this file, grant workspace.read
- 言語
>=0.1.1, <0.2.0- ホスト
>=0.1.3, <0.2.0- 必要なもの
- workspace >=0.1.2, <0.2.0
ソース
// Purpose: bring a symbol's chart to the front, opening one if there is // none — the "go to BTCUSDT" of a workspace. // Category: workspace // Permissions: workspace.read, workspace.write // Preconditions: a terminal window; the symbol offered by the terminal // Side effects: CHANGES YOUR WORKSPACE — focuses a chart, or opens one (at // 15m) when there is none for the symbol. // Run: in TTT, open the T0 Editor, open this file, grant workspace.read // and workspace.write, Run. Change `symbol`. lang ">=0.1.1, <0.2.0"; host "ttt" ">=0.1.3, <0.2.0"; requires "workspace" ">=0.1.2, <0.2.0"; fn main() -> Result<Unit, Error> { let symbol = "ETHUSDT"; for c in workspace.charts() { if c.symbol == symbol { workspace.focus_chart(c.chart)?; print("focused the " + symbol + " " + c.timeframe + " chart"); return Ok(()); } } let opened = workspace.open_chart(symbol, "15m")?; print("there was none: opened " + opened.symbol + " " + opened.timeframe); return Ok(()); }