It is usually a safeguard, not a bug. With default settings, NinjaTrader 8 stops a strategy when the broker rejects an order, when the connection drops for over 10 seconds in certain cases, or when it drops too many times in a row. Before changing anything, find out which of the three it was.
On this page
1. The broker rejected an order
This is the default behavior, RealtimeErrorHandling.StopCancelClose. When an order comes back rejected, the strategy stops, cancels its working orders and sends one close order for each position it manages. That's why it can look as if it disabled itself and took you out of the market too.
What to check: Find the order in the Rejected state and read the reason before enabling the strategy again.
2. The connection dropped
With ConnectionLossHandling at its default, Recalculate, the strategy stops in three cases: if the data feed is down for longer than DisconnectDelaySeconds, 10 seconds by default; if data and order feeds are both down for that long; or if the order feed is down and the strategy places an order action meanwhile. If the connection returns sooner, it carries on as normal.
What to check: Check what time it disconnected and how long the outage lasted.
3. The connection is unstable
NinjaTrader limits restart attempts. By default, NumberRestartAttempts is 4 and RestartsWithinMinutes is 5: go over 4 attempts in 5 minutes and the strategy stops and gives up. The guide says this exists to stop it when the connection can't stay stable.
What to check: If you see several outages in a row, fix the connection before touching these values.
What to do on a rejection
| Value | What it does |
|---|---|
StopCancelClose | Default. Stops the strategy, cancels orders and closes its positions. |
StopCancelCloseIgnoreRejects | Does the same on any error except order rejections. |
IgnoreAllErrors | Ignores order errors and keeps running. |
Be careful with IgnoreAllErrors. The guide warns it can have serious adverse effects unless you've programmed your own rejection handling in OnOrderUpdate(), and says that's only for experienced programmers. The dangerous case is simple: if your stop is rejected and nothing handles it, the position stays open with no protection. These properties should only be set in State.SetDefaults or State.Configure.
What to do on a disconnect
| Value | What it does |
|---|---|
Recalculate | Default. If the strategy was stopped, it tries to recalculate its position when the connection returns. |
KeepRunning | Keeps running and resumes as if no disconnect occurred. |
StopStrategy | Stops it after DisconnectDelaySeconds and takes no action when the connection returns. |
What to do when it happens
- Don't enable it again right away.
- Check your real position and active orders on the account.
- Look in the log for the exact time and whether there was a rejection or a disconnect.
- Fix the cause and pick the right Start Behavior when you enable it.
- If the PC or a restart was the problem, read why bots stop at night.
On a prop firm account, stopping usually beats running blind. A position with no stop can use up your drawdown in minutes. If you change these settings, test them first in simulation, with deliberate disconnects.
Want someone to review it? We check how your NinjaScript strategy reacts to rejections and disconnects.
Review from $90 Analyze NinjaTrader with AISources
- RealtimeErrorHandling (NinjaScript Language Reference)
- ConnectionLossHandling (NinjaScript Language Reference)
- DisconnectDelaySeconds (NinjaScript Language Reference)
- NumberRestartAttempts (NinjaScript Language Reference)
- RestartsWithinMinutes (NinjaScript Language Reference)
Keep reading
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 workbookGet 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, $9Educational content based on the official NinjaTrader documentation. Not investment advice. Test any change on a simulation account before using it live.