Script executions

Script executions is a setting that controls when the strategy script is recalculated relative to bar lifecycle events. By default, the script runs once per bar at its close. Additional modes allow you to trigger recalculation on order fills, on every realtime tick, or on every simulated historical tick. The number of executions in the latter mode depends on the Bar detalization setting: the more ticks are available per bar, the more frequently the script runs.

How it works

The Script executions control is located in the Detalization and Execution section of strategy settings. It is presented as a dropdown with multiple independent checkboxes. On bar close is always active and cannot be disabled — all other modes are additive.

Execution modes

  • On bar close (default): The standard execution model. The script is calculated once at the close of each bar — both historical and realtime. This is the baseline mode and is always enabled.
  • On order fill: An additional recalculation triggered immediately after a trade fill. This mode provides fast access to the updated account state right after an order is executed, without waiting for the next bar to close.
  • On realtime bar tick: For realtime bars only: the script is recalculated on every incoming tick within the current open bar. Has no effect on historical data.
  • On history bar tick (Premium): For historical bars: simulates intra-bar tick execution by replaying each bar as a sequence of price ticks. The number of ticks per bar — and therefore the number of script executions — depends on the Bar detalization setting. Price visibility corrections ensure the script can only "see" prices that have already occurred within that bar, maximizing backtesting realism. See also: Bar detalization.

! Note: On history bar tick is available on standard candlestick charts only. It is not available on Heikin Ashi or other non-standard chart types.

On history bar tick: price visibility rules

When this mode is active, each historical bar is replayed as 4 sequential ticks. The order of ticks depends on the bar's price path (OHLC or OLHC). On each tick, only the prices that have "already happened" are visible — future prices within the bar are masked.

See also: Bar detalization → Resolution-to-tick mapping table for details on how the number of simulated ticks per bar is determined based on chart resolution.

OHLC order

Tick

Open

High

Low

Close

Open

= Open

= Open

= Open

High

= Open

= High

Low

= Low

Close

OLHC order

Tick

Open

Low

High

Close

Open

= Open

= Open

= Open

Low

= Open

= Low

High

= High

Close

Main use cases

  • Higher execution precision on fills: Enable On order fill if your strategy logic needs to react immediately after a trade is executed — for example, to place a protective stop right after entry without waiting for the next bar.
  • Realtime responsiveness: Use On realtime bar tick when the strategy must respond to every price update on the live bar, such as for scalping or tick-sensitive exit logic.
  • Realistic historical simulation: Enable On history bar tick to stress-test strategies that rely on intra-bar price movement. The price visibility model prevents look-ahead bias, making backtests more conservative and realistic.

Diagnosing exit quality: Compare results with and without On history bar tick to identify if your exits are sensitive to the exact tick sequence within a bar. A significant performance difference between OHLC and OLHC modes may indicate fragile exit logic.