Black Friday, until December 2: FONDEOREAL gives 30% off the 50K, 20% off the 100K and 10% off the 150K at FTMO Futures. See the offer →

Lab · November 2026 · 3 min read

NinjaTrader 8 Closing Positions at Session End? Why

Why your NinjaTrader 8 strategy exits before the session ends: Exit on session close, the 30 seconds and the Trading Hours template, based on the official guide.

It's most likely Exit on session close, which is on by default. In real time, 30 seconds before the session ends, the strategy cancels its orders and closes its positions. If it seems to close at an odd time, check the Trading Hours template: that's where the time comes from.

On this page
  1. What it does exactly
  2. Where the time comes from
  3. Why the backtest exits at a different time
  4. Three confusing cases
  5. If you want to keep the position
  6. How to check it
  7. Sources

What it does exactly

IsExitOnSessionCloseStrategy is true by default. It cancels all strategy-generated orders and closes open strategy positions at the session close. On multi-timeframe or multi-instrument strategies it acts at the close of any of their sessions, across all instruments.

Where the time comes from

ExitOnSessionCloseSeconds defaults to 30 and counts back from the EOD time in the strategy's Trading Hours template. That's why a template that differs from your real schedule makes the exit come earlier than you expect. You can change both settings in the strategy window or in OnStateChange(), during State.SetDefaults or State.Configure.

Why the backtest exits at a different time

The seconds setting only works in real time. On historical data, the position exits at the close of the session's last bar. That gap changes the exit price and is one more reason a backtest doesn't match live trading.

Three confusing cases

If you want to keep the position

Turning the setting off means the strategy won't exit through this feature, so the position can carry into the next day. Before you do, decide what happens if the PC or connection fails overnight. Also review what a disconnect does.

How to check it

  1. Look at the exit time in your executions list.
  2. Open the strategy settings and check Exit on session close and its seconds.
  3. Open its Trading Hours template and check the EOD time.
  4. Confirm that time matches the hours you want to trade.

On a prop firm account, this time matters. Many firms set a time to be out of positions, and it won't necessarily match your template. Confirm your firm's schedule and leave a margin: if your exit relies on NinjaTrader's session end, make sure it comes before theirs.

Want someone to review it? We check the schedules and exits of your NinjaScript strategy.

Review from $90 Analyze NinjaTrader with AI

Sources

Keep reading

Practise an evaluation, freeAll 91 articles →

Free: The Other Half Workbook. Nine templates for trading with a cool head: your one-page plan, the pre-session checklist, the twelve-patterns test, your size and the bill for your mistakes.

Get the free workbook

Get ready for 2027: the Trader Planner. Each day's US releases in New York time, your pre-market routine and a log for every session.

Paperback on Amazon, $16.99 Get the PDF, $9

Educational content based on the official NinjaTrader documentation. Not investment advice. Test any change on a simulation account before using it live.