You enable a NinjaTrader 8 strategy an hour after the open. Its name turns orange on the Strategies tab, the chart shows trades being taken, and nothing reaches your account. Or the opposite happens: the strategy starts, sends a sell order to close a long it thinks it holds, and your flat account is suddenly short one contract.
Both situations come from the same dropdown: Start behavior. It decides what a strategy does in the first seconds after you enable it, and it is the setting that determines whether the position your strategy believes it has matches the position your account really has. This guide walks through all five options using the NinjaTrader 8 Help Guide, then covers how we think about the choice on a prop firm account.
Strategy Position vs Account Position
Start behavior only makes sense once you separate two things NinjaTrader tracks independently.
- Strategy Position. The Help Guide describes this as a virtual position, created by the entry and exit executions the strategy generates. It is independent of any other running strategy and of your account.
- Account Position. The position you really hold in the trading account, whether that is the Sim101 simulation account or a live brokerage account.
Most of the time you want those two to match in size and direction. They drift apart more easily than people expect. Running several strategies on one market in the same account will do it. So will placing discretionary trades on a market a strategy is trading.
The mid-session start
The most common cause is simpler. When you enable a strategy, NinjaTrader runs it across every historical bar loaded on the chart to work out what position it would be in if it had been running all along. That result becomes the Strategy Position.
Suppose you start a strategy one hour into the session, and during that hour the strategy's rules would have gone long one contract and stayed long. The Strategy Position is now long 1. Nothing was executed in your account, so the Account Position is flat. The two are out of sync before the strategy has sent a single real order.
The Help Guide spells out what happens if you leave it that way. When the strategy later closes its long with a sell order, the Strategy Position goes flat and the Account Position goes short. You now hold a live short the strategy does not know about and will not manage.
Start behavior is NinjaTrader's answer to that problem. You pick it in the strategy's properties when you add the strategy, under Start behavior.
The Five Start Behaviors at a Glance
NinjaScript exposes five values on the StartBehavior property. Four appear for every strategy. The fifth only shows up when the developer has built the strategy for it.
| Start behavior | What it does at startup | Can it send a market order on its own? |
|---|---|---|
| Wait until flat | Trades virtually until the Strategy Position is flat, then goes live | No |
| Wait until flat, synchronize account | Flattens the account if needed, then waits for the strategy to be flat | Yes, to flatten the account |
| Immediately submit | Starts managing orders right away and assumes the account already matches | No |
| Immediately submit, synchronize account | Starts right away and trades the account into the Strategy Position | Yes, to match the strategy |
| Adopt account position | Ignores the historical virtual position and starts from the real account position | Depends on how the strategy is coded |
Wait Until Flat (the Default)
StartBehavior.WaitUntilFlat is the default for every strategy. The Help Guide calls it the least disruptive option for your current Account Position, and it assumes your account is flat.
On startup the strategy first looks for active orders it generated earlier on the account and cancels them. If it cannot cancel them and get confirmation within 40 seconds, the strategy does not start and NinjaTrader issues an alert. After that, one of two things happens:
- The Strategy Position is flat. NinjaTrader assumes the strategy and the account are in sync. The next order the strategy places is a live order.
- The Strategy Position is not flat. The strategy places its trades in a virtual sense until the Strategy Position reaches or crosses flat. From that point every order goes live.
That second case is the orange strategy. The Help Guide's Strategies tab page says an orange highlighted strategy name means the strategy is waiting to reach a flat position so it is in sync with the account before fully starting. Green means running. Black means disabled. An orange name is not a fault. The strategy is finishing a trade that only exists on paper.
There is one gap to know about. Wait until flat assumes the account is flat, and it never checks. The Help Guide marks this as critical: if your account is not flat at the moment the Strategy Position reaches flat, the two will not be in sync.
Wait Until Flat, Synchronize Account
This is Wait until flat with the missing check added.
After cancelling its old orders, the strategy compares your Account Position to flat. On a multi-instrument strategy it does this for every instrument the strategy uses.
- If the account is already flat, no order is sent. The strategy waits for its own position to reach flat, then trades live.
- If the account is not flat, NinjaTrader submits one or more market orders to flatten it. The strategy then waits for its own position to reach flat before sending live orders.
Read that second bullet twice. If you have any position on that instrument in that account, enabling the strategy closes it at market.
Immediately Submit
With StartBehavior.ImmediatelySubmit, the strategy begins executing orders the moment it starts. There is no virtual phase and no waiting. The Help Guide says to use it only when you are sure your Account Position is already the way you want it relative to the Strategy Position.
The order handling on startup is more involved than with Wait until flat:
- Active orders on the account that the strategy generated earlier, and that do not match an active strategy order, are cancelled. The same 40-second confirmation rule applies.
- Active account orders that do match are mapped to the strategy's active orders.
- Any active strategy orders left without a partner are submitted live.
"Match" is strict. According to the Help Guide, an earlier order matches only when the order action, order type, quantity, limit price and stop price are exactly identical. A stop that is one tick different is not a match, so it gets cancelled and replaced.
This setting does nothing about positions. In the mid-session example, the strategy would submit its working exit orders live against a position the account does not hold. Use it only after you have made the account match, usually by hand.
Immediately Submit, Synchronize Account
This option runs the same order matching as Immediately submit, then compares the Account Position to the Strategy Position, instrument by instrument.
- If they match, no order is sent and the strategy starts managing its position.
- If they do not match, NinjaTrader submits one or more market orders to make the account match the strategy, and the strategy starts managing its position.
The direction of the sync is the part people get backwards. The account is moved to the strategy. The strategy is not moved to the account. If the strategy calculated a long 2 position from historical bars and your account is flat, enabling it buys 2 contracts at market at the current price.
"Using Synchronize account can close or place live trades to your account" (NinjaTrader 8 Help Guide, Syncing Account Positions)
The Help Guide adds a note that applies to both synchronize options. The reconciling market order is submitted outside of the strategy, so the strategy cannot manage it from methods such as OnOrderUpdate() or OnExecution(). If your code tracks fills to place its stops and targets, it will not see this one.
Adopt Account Position
Adopt account position turns the logic around. The Help Guide says to use it when you want the strategy to disregard its historical virtual position and start in the same position as the real account.
You will only see it in the dropdown if the developer set IsAdoptAccountPositionAware to true. That property defaults to false, and the Help Guide says to set it to true only when the strategy has been specifically programmed to handle real-world account positions. It also comes with limits:
- Only one strategy with this setting can be started at a time for a given account and instrument.
- The account and instrument must not have working orders that were submitted outside the strategy or by another instance of the same strategy. If NinjaTrader detects one, the strategy cannot start until you deal with those orders manually.
Every one of these options syncs once, at startup
The Help Guide is clear that Start behavior only helps you sync the Account Position to the Strategy Position one time, when the strategy starts. It does not keep them in sync afterward. Active orders on the account that your strategy did not generate are not cancelled at start. Manual trades, or several strategies on the same instrument, can still pull the account away from the strategy later.
Setting Start Behavior in Code
If you write your own strategies, you can set the default in OnStateChange(). This is the pattern from the Help Guide:
if (State == State.SetDefaults)
{
StartBehavior = StartBehavior.WaitUntilFlat;
}
One more warning from the Help Guide belongs here. If your strategy keeps references to orders that were submitted on historical data and then carried into real time, you must update each reference to the newly submitted real-time order. Otherwise errors may occur when you try to cancel it. NinjaScript provides GetRealtimeOrder() for this. The Help Guide says to call it once per order object, in OnOrderUpdate().
Synchronize All Strategies
There is also a manual version of the sync. Right-click the grid on the Control Center's Strategies tab and you will find Synchronize All Strategies.
According to the Help Guide, it scans the Strategy Position of every enabled strategy that is not set to Wait until flat, for each account and instrument combination, adds those positions together, and compares the total to the Account Position. If they differ, a market order is sent to the account to match the total.
The Help Guide's own example has four strategies on a flat live account: two are long 1 on Immediately submit, one is flat on Immediately submit, and one is short 2 on Wait until flat. The Wait until flat strategy is left out of the math, so the aggregate is long 2, and choosing Synchronize All Strategies buys 2 contracts. Know what the total will be before you click it.
Want a strategy that is ready to run?
NQ Ultra is a ready-to-run NinjaTrader 8 strategy for NQ futures, built for traders running prop firm accounts. Start from a finished system instead of debugging order handling.
Get NQ Ultra on WhopWhich Start Behavior Fits a Prop Firm Account?
What follows is our view, not NinjaTrader's. If the strategy you run came with setup instructions, follow the vendor's recommended setting first, because the strategy was built and tested around it.
For most intraday strategies, the default is the right call. Wait until flat never sends an order you did not ask for. The worst case is that the strategy sits orange for a while and misses the rest of a trade it was not in anyway. On an evaluation or funded account, a missed trade costs nothing. A surprise market order can cost a lot.
Be careful with both synchronize options. Suppose your strategy shows long 2 from historical bars when you restart it mid-morning. Immediately submit, synchronize account buys 2 contracts at the current price. On an account with a daily loss limit or a trailing drawdown, that is a trade you did not size. A market order at restart can also land at a time your firm restricts, so check your firm's current rules before you rely on any automatic sync.
Immediately submit suits recovery, not routine starts. It earns its place when the platform or connection dropped while the strategy was in a live trade, the account still holds that position, and you want the strategy to pick its working orders back up. Even then, confirm with your own eyes that the Account Position equals the Strategy Position before you enable it.
Start flat when you can. If the Strategy Position is flat on historical data and the account is flat, every option behaves the same way and the next order is live. A strategy that closes its trades by the end of each session and is enabled before the next one begins will usually start in exactly that state. The session boundaries come from your template, which we covered in our guide to NinjaTrader 8 Trading Hours templates.
A Restart Checklist
Restarts are where start behavior bites, whether you planned the restart or your machine did it for you. If you run on a remote server, our article on using a VPS for a NinjaTrader 8 algo covers keeping the platform up in the first place. When you do have to restart, go through this list:
- Check the account first. Look at the Positions and Orders tabs in the Control Center. Know whether you are flat and whether any working orders are sitting on the instrument.
- Clear orders the strategy did not create. Start behavior does not cancel orders that came from somewhere else, and a leftover stop or limit can put you out of sync later.
- Confirm the Start behavior setting before you tick Enabled. Do not assume it is still on the default, especially on a strategy someone else configured.
- Read the color. Green means the strategy is live. Orange means it is waiting for its virtual position to go flat. If it stays orange for a long time, the historical trade it is finishing simply has not closed yet.
- Keep your hands off the instrument. Manual trades on a market a strategy is trading are one of the causes of drift the Help Guide names directly.
If the strategy is enabled and green and still takes no trades, start behavior is probably not the cause. Our checklist for why a NinjaTrader 8 strategy stopped trading covers the other usual suspects.
Start behavior is easy to ignore because the default works most days. It matters on the day you restart in the middle of a trade, enable a strategy late, or inherit someone else's workspace. Know which of the five options your strategy uses, know whether it can send a market order by itself, and check the account against the strategy every time you enable it.