← All examples
Example 28
Trigger time report
the script of a Time Trigger Line: when the market clock reaches the
- Category
- Workspace: reads or changes charts and panels
- Permissions
- workspace.read
- Before you run it
- set as the script of a Time Trigger Line, with
- What it does
- none (read-only)
- How to run it
- place a Time Trigger Line, open its properties, Trigger page:
- Language
>=0.1.1, <0.2.0- Host
>=0.1.5, <0.2.0- Needs
- workspace >=0.1.1, <0.2.0event >=0.1.0, <0.2.0
Source
// Purpose: the script of a Time Trigger Line: when the market clock reaches the // line, report the workspace — what it is looking at when that time comes. // Category: workspace // Permissions: workspace.read // Preconditions: set as the script of a Time Trigger Line, with // workspace.read ticked on its Trigger page // Side effects: none (read-only) // Run: place a Time Trigger Line, open its properties, Trigger page: // Choose… this file, tick workspace.read, and set it to fire in Replay or // Both to watch it arrive in a replay. lang ">=0.1.1, <0.2.0"; host "ttt" ">=0.1.5, <0.2.0"; requires "workspace" ">=0.1.1, <0.2.0"; requires "event" ">=0.1.0, <0.2.0"; fn main() { let e = event.current(); print("the clock reached the line (" + e.kind + ") at " + to_string(e.time)); match e.price { Some(p) => print("the price then: " + to_string(p)), None => print("no price was known"), } for c in workspace.charts() { print(c.symbol + " " + c.timeframe); } }