Strategy timing

3 min read

NinjaTrader exit on session close: real-time and backtest timing

The seconds offset affects real-time exits. Historical bars and multi-series sessions can produce different closing times.

Conceptual illustration of a stopwatch and amber trigger marker before a navy session-end boundary on a segmented track.

Quick answer

NinjaTrader’s Exit on session close closes positions belonging to that strategy, using its session settings. The seconds offset controls the lead time in real time; changing it does not move historical backtest exits ahead of the final session bar.

Find the selected strategy’s exit settings

In the chart’s Strategies window, select the instance in Configured. Confirm its Account and Data Series, then inspect Exit on session close and Exit on session close seconds.

In NinjaScript, the corresponding properties are IsExitOnSessionCloseStrategy and ExitOnSessionCloseSeconds. Their defaults are enabled and 30 seconds; inspect the instance’s actual values. When setting them in code, use OnStateChange() during State.SetDefaults or State.Configure.

Count back from the template’s EOD

The seconds value is measured from the EOD boundary in the strategy’s Trading Hours template. For an illustrative EOD of 17:00:00 and a 30-second offset, the real-time trigger time is 16:59:30. This is a configuration example, not an exchange schedule or a guaranteed fill time.

Read the template’s time zone and the definition for the relevant trading date. An Early Close holiday can change the EOD boundary used for that date.

Why a backtest exit can look later

More granular historical order-fill resolution does not detach this exit from the primary series’ bar. NinjaTrader documents the feature for intraday strategies and warns against combining it with Daily Bars and High Order Fill Resolution.

Break at EOD affects bar construction: enabling it can end a bar at the session boundary before its normal completion criteria are met. Disabling it lets that bar finish according to those criteria.

Execution contextWhat controls the exit time
Real timeThe seconds offset triggers session-close logic before the template’s EOD.
Historical time-based barsThe strategy exits at the close of the session’s final bar. The seconds offset does not advance that historical exit.
Historical Renko with Break at EOD offThe final bar can extend beyond the session boundary, allowing the exit to occur after the session closes.

A multi-series strategy can react to any session close

With multiple time frames or instruments, any session closing can trigger the exit. NinjaTrader cancels the strategy’s orders across its instruments and closes its positions. Check each series’ sessions when diagnosing an unexpected exit.

Official sources

Platform monitoring

Monitor the platform running your strategy

Ninja Watchdog monitors NinjaTrader and supports recovery after platform interruptions. It does not directly place, modify or cancel orders. Email alerts are available today; SMS and WhatsApp alerts are coming soon.

Explore the free trial