December 2, 2026

NinjaTrader Automated Trading: Start Behavior, Position Sync and Disconnects

Most surprises with a NinjaTrader 8 trading bot come from one mismatch: the strategy's own virtual position is not the same thing as the position in your account. When you enable a NinjaScript strategy, NinjaTrader first runs it over the historical bars on the chart and gives it the position it would hold. If that position doesn't match your real account and you haven't chosen a start behavior that handles it, the strategy's next exit can open a new, unintended live position. Before you enable automation on a live account, check four settings: Start behavior (default: Wait until flat), connection loss handling (default: Recalculate, after a 10-second disconnect delay), real-time error handling (default: stop, cancel orders and close the position on a rejected order) and Exit on session close (default: on).

This guide explains what each of those settings does, based on NinjaTrader's current NinjaScript and Help Guide documentation, and turns it into a pre-live checklist. It's written for futures traders running their own strategy or a purchased NinjaScript strategy. It is documentation research, not a hands-on test: we did not run these settings on a live account and make no claims about fills, speed or profitability. If you are still choosing a platform, start with our futures trading bot comparison.

Diagram showing a NinjaTrader 8 strategy enabled mid-session holding a virtual long 1 position while the account is flat, the strategy's sell order leaving the account short 1, and a table of what each of the five Start behavior options does
How a strategy position and an account position drift apart, and what each Start behavior option does about it. Summarized from the NinjaTrader 8 Help Guide. Illustration: Trading Bot Experts.

How NinjaTrader 8 runs an automated strategy

In NinjaTrader 8, an automated strategy is a NinjaScript strategy: C# code you write yourself, code generated by Strategy Builder (its guided step-by-step builder or the newer AI Strategy Builder, both of which produce NinjaScript), or a third-party package you import. You run it by opening the Strategies window from a chart (or adding it in the Control Center's Strategies tab), choosing the account and data series, setting its properties and setting Enabled to true. NinjaTrader's documentation is blunt about what that means: a running strategy is a self-contained automated trading system, and the orders it generates are live.

Two details catch new users out:

  • Manual interference can stop the strategy. NinjaTrader warns that manually cancelling strategy-generated orders can cause the strategy to stop executing as expected, and selecting Close on an account and instrument that has a strategy running turns the strategy off. To cancel its orders, stop the strategy itself.
  • Historical calculation happens first. Before going live, the strategy processes every historical bar loaded on the chart. That's what creates the "virtual" strategy position described below.

Strategy position vs account position

NinjaTrader tracks two positions:

  • The strategy position is a virtual position created by the strategy's own entry and exit executions. It is independent of other strategies and of the account.
  • The account position is what you actually hold in the account the strategy trades, whether that's the internal Sim101 simulation account or a live brokerage account.

You normally want them to match. NinjaTrader lists the common reasons they don't: running more than one strategy on the same market, trading the same market manually from the SuperDOM or Chart Trader, and starting a strategy partway through a session.

The documentation's own example is worth walking through. You enable a strategy an hour after the session opens. During that historical hour, the strategy would have bought one contract and still be holding it, so its strategy position is long 1. But no real order was ever placed, so the account is flat. If nothing reconciles the two, the strategy's next exit, a sell of one contract, takes the strategy position to flat and leaves the account short one contract. That's a real, unplanned position created by a correctly coded strategy.

Two places show you whether you're in sync. In the Control Center's Strategies tab, the Position column is the strategy position, Acct. position is the account position (including positions the strategy didn't enter), and the Sync column shows true when they match. The strategy name's color shows its state: green is running, orange is waiting to reach flat so it can sync, and black is disabled.

The five Start behavior options compared

The Start behavior property decides what happens to that mismatch when the strategy is enabled. In code it's the StartBehavior property, and the default is WaitUntilFlat. Every option first deals with active orders the strategy previously generated on the account; if NinjaTrader can't cancel those and get confirmation within 40 seconds, the strategy doesn't start and NinjaTrader raises an alert.

Start behaviorWhat it assumesCan NinjaTrader send its own market order?When strategy orders go liveFits when
Wait until flat (default)The account is flatNoOnce the strategy position reaches or crosses flat; until then trades are virtualYour account really is flat in that instrument and no one else trades it
Wait until flat, synchronize accountYou want to start from flatYes: market order(s) to flatten the account if it isn't flatOnce the strategy position reaches or crosses flatYou want NinjaTrader to clear a leftover position and then start cleanly
Immediately submitThe account already matches the strategy positionNoImmediately; it maps matching working orders and submits the restYou've manually set the account to the strategy position, such as after a planned restart
Immediately submit, synchronize accountThe strategy position is correctYes: market order(s) so the account matches the strategy positionImmediatelyYou accept that NinjaTrader may trade at market on start to match the strategy
Adopt account positionThe real account position is correctNo reconciliation to the historical position; the strategy starts from the account's positionImmediatelyOnly for strategies coded with IsAdoptAccountPositionAware; one such strategy per account and instrument at a time

A few documented caveats change how you should read that table:

  • Sync happens once, at start. These options sync the account to the strategy only on startup. They don't keep the two in sync afterward.
  • Some orders are left alone. NinjaTrader doesn't cancel active orders that were on the account before the strategy started if the strategy didn't generate them, and those orders can knock the positions out of sync.
  • "Synchronize account" can trade. NinjaTrader warns that the synchronize options can close or place live trades. The reconciliation order is a market order submitted outside the strategy, so the strategy's OnOrderUpdate() and OnExecution() methods can't manage it.
  • Wait until flat has a trap. If the account isn't actually flat when the strategy position reaches flat, the strategy goes live out of sync. The default is the least disruptive option, not an automatic safety net.
  • Order matching is exact. For the Immediately submit options, a leftover order only maps to an active strategy order if the action, type, quantity, limit price and stop price are identical.
  • Adopt account position isn't always offered. It appears only if the strategy's developer set IsAdoptAccountPositionAware to true. If you don't see it on a purchased strategy, the vendor didn't program it to handle real account positions.

There's also a Synchronize All Strategies command in the Strategies tab. It adds up the strategy positions of all enabled strategies that are not set to Wait until flat for each account and instrument, compares the total to the account and sends a market order for any difference. In NinjaTrader's example, two strategies each long 1 on a flat account produce a market order to buy 2 contracts. Treat it as a trade, not a refresh button.

Which start behavior should you use?

There's no universally right answer, but the documentation supports a simple decision path:

  1. Is anything else trading this account and instrument? If you also trade it by hand or run a second strategy on it, no start option will keep positions aligned afterward. Separate them by account or instrument first.
  2. Is the account flat in this instrument, with no stray working orders? If yes, the default Wait until flat is usually the least surprising choice. Expect the strategy name to stay orange until its virtual position reaches flat.
  3. Are you restarting a strategy that already holds a real position? Either the strategy supports Adopt account position, or you confirm the account matches the strategy position and use Immediately submit. If you can't confirm either, flatten manually and start from flat.
  4. Do you want NinjaTrader to fix a mismatch for you? Only then choose a "synchronize account" option, and accept that it may place a market order at whatever price is available when you click enable.

Whatever you choose, check the Strategies tab's Sync column immediately after enabling, and again after any manual action on that account.

Get the Top 5 Bots for Early Retirement report:

What happens when the connection drops

Connection loss handling is set by the ConnectionLossHandling property, with the disconnect threshold in DisconnectDelaySeconds (default 10 seconds).

OptionDocumented behavior
Recalculate (default)If the strategy was stopped by the disconnect, it tries to recalculate its strategy position when the connection is re-established. If the connection returns before the strategy was stopped, it keeps running as if nothing happened.
Keep runningThe strategy keeps running and resumes as if no disconnect occurred.
Stop strategyThe strategy stops after a disconnect longer than the delay; nothing happens when the connection returns.

Under the default, NinjaTrader stops the strategy when the data feed is down for longer than the delay, when the order feed is down and the strategy tries an order action during the outage, or when both feeds are down for longer than the delay. Note what isn't promised: none of these modes describes closing your open account position for you. If your bot can be stopped mid-trade, decide in advance whether working stop orders at the broker should protect the position, and how you'll be alerted. Our guide to monitoring a live trading bot covers alerting, and our VPS hosting guide covers keeping a desktop platform online.

What happens when an order is rejected

The RealtimeErrorHandling property controls what a strategy does when the broker returns one of its orders as rejected. By default (StopCancelClose), the strategy stops, cancels its remaining working orders and closes the positions it manages with a Close order for each position. StopCancelCloseIgnoreRejects keeps that behavior for other errors but not for rejections, and IgnoreAllErrors ignores order errors and keeps running.

NinjaTrader flags IgnoreAllErrors as able to have "serious adverse affects" unless you've programmed your own rejection handling in OnOrderUpdate(), and says user-defined rejection handling should only be attempted by experienced programmers. If you bought a strategy, ask the vendor which mode it uses and what its code does when a stop-loss order is rejected. A vague answer is useful information.

Session close and ATM strategy handoff

Exit on session close (IsExitOnSessionCloseStrategy, on by default) cancels the strategy's orders and closes its positions at the end of the session, with ExitOnSessionCloseSeconds setting how many seconds before the close it acts. NinjaTrader says it's designed for intraday strategies only, and warns that with non-time-based bars such as Renko and Break at EOD off, the exit can trigger after the session close in historical processing. For a swing strategy that holds overnight, this is a setting to turn off deliberately, not to discover the next morning.

Some strategies hand trades to an ATM Strategy (NinjaTrader's preset stop and target brackets) with AtmStrategyCreate(). According to the documentation:

  • ATM Strategies run in real time only, so that part of the logic can't be backtested.
  • Executions from the ATM don't affect the hosting strategy's position, profit and loss or performance tracking, and settings such as Entries per direction and Exit on session close don't apply to it.
  • Closing it incorrectly from an order entry window such as the SuperDOM closes the account and instrument position, terminates all strategies and cancels all orders. NinjaTrader describes the correct method: the middle mouse button on CLOSE, or a left click when the window is set to display the selected ATM strategy only.

So a backtest of a strategy that relies on ATM handoff doesn't show the trades that the ATM actually manages.

Why the backtest and the live strategy can differ

NinjaTrader's settings also explain several common gaps between Strategy Analyzer results and live behavior:

  • Calculate mode. The default is On bar close. Historical bars only carry OHLC data, so historical processing runs once per bar even if you choose On each tick or On price change, unless you use Tick Replay or add a finer data series. A tick-driven strategy can therefore behave differently live than it did in the backtest.
  • Fill simulation. At the default Standard order fill resolution, NinjaTrader splits each historical bar into three virtual price moves based on whether the open is closer to the high or the low. High resolution uses a more granular secondary series, but it can't be used with multi-timeframe or multi-instrument strategies or with Tick Replay.
  • Slippage. Backtest slippage is set in ticks and applies only to market, stop-market and market-if-touched orders, so limit-order strategies get no added slippage. See our explainer on slippage in trading.

None of this makes a backtest useless; it means you need a forward test. Our guides on backtesting and testing a bot before going live cover the wider process.

Pre-live checklist for a NinjaTrader 8 strategy

  1. Run the strategy on Sim101 with a live data connection, or on the Playback connection over recorded data, and enable it mid-session at least once to watch the start behavior in action.
  2. Write down the Start behavior, Connection loss handling, Disconnect delay, Realtime error handling, Exit on session close and Calculate settings the strategy actually uses. For purchased strategies, ask the vendor which are hard-coded.
  3. Give the strategy its own account or instrument, or accept that manual trades and other strategies on it will break sync.
  4. Before enabling, check for working orders the strategy didn't create; NinjaTrader won't cancel them for you.
  5. After enabling, confirm the strategy name is green (or orange, if you expect it to wait for flat) and the Sync column shows true.
  6. Decide what protects an open position if the strategy stops during a disconnect or a rejection, and test the alert path.
  7. If the strategy uses ATM handoff, practice closing the ATM correctly in simulation before you trade it live.
  8. Start live with the smallest size you can, such as micro contracts, and compare strategy executions with account executions daily.

For broker-side checks before connecting any automation to a live account, see our brokerage connection checklist. If you're comparing NinjaTrader with other desktop platforms on restart behavior, our ATAS vs Sierra Chart automation guide covers how those two handle disconnects. And if a live strategy has already lost money because of a mismatch, read what to do when a trading bot loses money.

Frequently asked questions

Why is my NinjaTrader strategy orange and not taking trades?

An orange strategy name in the Strategies tab means the strategy is waiting to reach a flat position so it can sync with the account. With the default Wait until flat start behavior, a strategy whose historical calculation ended in a position places trades virtually until that strategy position reaches or crosses flat, and only then sends live orders.

Why did my NinjaTrader strategy open a position in the wrong direction?

The most common documented cause is a strategy position that doesn't match the account position. For example, a strategy that holds a virtual long 1 from historical bars on a flat account will sell 1 to exit, leaving the account short 1. Manual trades or another strategy on the same instrument can cause the same mismatch.

Does NinjaTrader close my position if the connection drops?

Connection loss handling decides whether the strategy keeps running, recalculates or stops after a disconnect longer than the disconnect delay, which defaults to 10 seconds. None of those modes is documented as closing your account position, so plan how working stop orders at the broker and your own alerts will protect an open trade.

What does "Adopt account position" do in NinjaTrader 8?

It lets a strategy ignore its historical virtual position and start from the real account position. It's only offered when the strategy's code sets IsAdoptAccountPositionAware to true, and only one strategy with this setting can start at a time for an account and instrument.

Can I backtest a NinjaTrader strategy that uses ATM Strategies?

Not the ATM part. NinjaTrader documents that ATM Strategies run in real time only and don't execute on historical data, and their executions don't count toward the hosting strategy's position or performance. Forward-test those strategies in simulation instead.

Educational research based on NinjaTrader 8 Help Guide and NinjaScript documentation checked on December 2, 2026; default values and behavior can change between versions, so confirm them in your installed build. We did not run hands-on tests, and this article contains no sponsored or affiliate links. Nothing here is trading advice. Automated futures trading uses leverage and can lose more than your initial deposit.

Free Report

Before You Choose a Bot, Read This

Get our free Top 5 Bots for Early Retirement report plus The Bot Report newsletter — the bots we'd actually trust to compound over the long term.

By entering your email, you'll begin receiving The Bot Report newsletter as well as occasional updates. You can unsubscribe at any time. Our privacy policy.

Written by
Sofia Reyes
13 min read

Pseudonymous contributor to TradingBotExperts covering trading technology, brokers, and automation.