Quick answer
When a broker rejects an order from a running NinjaScript strategy, the default RealtimeErrorHandling setting, StopCancelClose, stops that strategy, cancels its remaining working orders and submits a close order for each distinct open position it manages. A disabled strategy can still have a close order awaiting a fill. Check the order and the account position separately.
Follow a rejected protective stop
Suppose a strategy’s buy entry fills and the broker then rejects its protective sell stop. The entry fill still stands. Under StopCancelClose, NinjaTrader stops the strategy, cancels any other working orders for that strategy and submits a separate order to close its open position. The rejected stop and the close order are two different orders.
If the rejected order was the entry itself and the strategy had no open position, there is no position for the default policy to close. The order name and filled quantity tell you which case you are looking at.
How the three RealtimeErrorHandling settings differ
This property belongs to the strategy. A NinjaScript developer sets it in OnStateChange() during State.SetDefaults or State.Configure. The setting matters when deciding who handles a rejection and what happens to the strategy afterward.
NinjaScript responses to real-time order errors
| Setting | What the strategy does |
|---|---|
| StopCancelClose (default) | Stops, cancels its remaining working orders and submits close orders for positions it manages. |
| StopCancelCloseIgnoreRejects | Excludes order rejections from the default response. Other order errors still trigger the default behavior. |
| IgnoreAllErrors | Continues running through order errors. The strategy author must implement any response the strategy needs. |
Check whether the close order filled
- In Control Center → Orders, filter by the affected account. Match the instrument, order name and time to identify the rejected entry or exit. Inspect its state and filled quantity.
- Find the separate close order, if one was submitted. Read its state and quantities. For example, an order for two contracts with one filled and one remaining has closed only one contract so far.
- In Control Center → Positions, check the open quantity for the same account and instrument. Another strategy or a manual trade can contribute to that account position, even when the stopped strategy has finished closing its own position.
What to capture in a custom rejection handler
For a strategy that handles its own rejections, OnOrderUpdate() supplies the order state for the update, an ErrorCode, and the broker’s comment. Record the signal name with those values so a rejected protective exit can be distinguished from a rejected entry. The Order object may already show a later state when the callback runs. Use the supplied orderState argument when recording the event.
NinjaTrader directs developers to OnExecutionUpdate() for logic driven by fills. A rejection is an order-state event. Whether a separate close order executed is a fill question. Selecting IgnoreAllErrors alone supplies no replacement protection for a rejected stop.
If a disconnect appeared in the same log
Look at the first event that affected the strategy. A broker rejection can occur while the connection is healthy. If the log instead starts with an interruption to the price feed or order connection, check ConnectionLossHandling and the strategy’s restart settings. The linked disconnect guide covers what happens when the connection returns.
Official sources
Platform monitoring
Get an email when NinjaTrader loses its connection
Ninja Watchdog monitors NinjaTrader connectivity and reports platform recovery by email. SMS and WhatsApp alerts are coming soon.
