Last Updated on 18 May 2023 by automiamo.com

Backtest and realtime execution

  • Scripts execute only once on historical bars (backtest execution).
  • By default, scripts only execute when the realtime bar closes (realtime execution).
  • Scripts execute every time an update occurs during a realtime bar (at the open of the realtime bar and then once per update), if parameter calc_on_every_tick=true.
    • I’d use calc_on_every_tick=true because it could be useful to target profit and exit automated trade with no waiting the bar close.
  • With calc_on_every_tick=true, because usually I want my strategy’s entry executions at the realtime bar closes only, use barstate.isconfirmed to do that.