User-supplied function that is called on arrival of a new price quote of any asset used in the strategy. This function can be used when an immediate reaction on every new price quote is required.
User-supplied function that is called once per minute (adjustable via TockTime), regardless of price quotes. This function can be used f.i. for periodic input/output tasks.
- The tick function is called not at fixed time intervals, but in irregular intervals, dependent on market activity. The more assets are traded, the more quotes will trigger a tick run. The tick function normally executes more frequently than the run function, but can also execute less often when few quotes are received, f.i. after market hours.
- The minimum time between two tick calls can be set up with TickTime. If a new quote arrives earlier, it is delayed until the TickTime is over.
- Asset, current ask price, current ask-bid spread, and time stamp of the
last quote can be evaluated with the Asset string variable, the priceClose function,
the Spread variable, and the seconds function.
- The same price quote can trigger a tick function as well as a TMF. The tick functions of all assets that had quotes in the last TickTime are executed first, afterwards all triggered TMFs are executed.
- In [Test] or [Train] mode or in the lookback period, the tick and tock functions are normally called only once per bar. But when the TICKS flag is set, the tick function is called at any new price quote dependent on the resolution of the historical data.
- Data series can not be created in a tick or tock function, and indicators that create data series can not be called; however data series
and indicators can be evaluated, using global variables or AssetVar variables.
Static series can be shifted in a tick or tock function by calling
- As long as the current bar is not finished, the current candle is incomplete, so its range and height can be very different to the preceding complete candles and should not be used for trade signals. The price functions also return different values because they retrieve their open, high, and low prices from the current incomplete candle.
// print every price quote in a file
strf("\n%i.%i %2i:%2i:%2.3f => %s %4.5f",
Bars and Candles, Bar, BarPeriod, TickTime, TMF, run, user supplied functions