StopWarden

Guides Updated

StopWarden is not open yet. This guide is general information about NinjaTrader 8 and does not depend on StopWarden. Get one email when it opens.

NinjaTrader "cancel orders on disable" settings, explained

Short answer: two checkboxes, whose values NinjaTrader copies into each strategy row when the row is added, decide what happens to a NinjaScript strategy's working orders when you disable it: Cancel entry orders when a strategy is disabled and Cancel exit orders when a strategy is disabled. Neither one closes an open position. With both checked, disabling a strategy that is in a position leaves that position open with no stop.

Where the settings are

Control Center > Tools > Settings > Strategies, in the NinjaScript section. Older 8.x builds call the menu item Options instead of Settings. [1][2]

SettingNinjaTrader's description
Cancel entry orders when a strategy is disabledEnables or disables automatic cancellation of a strategy's entry orders when the strategy is disabled.
Cancel exit orders when a strategy is disabledEnables or disables automatic cancellation of a strategy's exit orders when the strategy is disabled.

These settings do not stay linked to your strategies. In our own testing on NinjaTrader 8 (8.1.8.2), NinjaTrader copied the two values into a strategy row when the row was added, and the row kept them. A row added while the boxes were unchecked kept running with both off after the settings were later checked, so changing the setting afterwards did not change that row. NinjaTrader prints the row's own values in the Enabling NinjaScript strategy line of its log, so read that line for the strategy you run instead of trusting the checkboxes alone. StopWarden's own troubleshooting step for a row that has them off is to remove the row from the Strategies tab and add it again with both boxes checked. NinjaTrader's help guide [1][2] describes the settings themselves; the copy-into-the-row behavior comes from our own log and account observations, not from that guide.

Entry orders are the orders that open or add to a position (for example from EnterLong() or EnterLongLimit()). Exit orders are the stop, the target and any other order that closes the position (for example from SetStopLoss() or ExitLongStopMarket()).

What each combination does

EntryExitWhen you disable the strategyThe risk
OnOnAll of the strategy's working orders are cancelled.An open position stays open with no stop and no target. Close it yourself.
OffOnPending entries stay working; stops and targets are cancelled.A leftover entry can fill later and open a position nothing is managing, with no stop.
OnOffPending entries are cancelled; the stop and target stay working.The position keeps its stop at the broker, but nothing manages it any more. If the position is closed some other way, the stop and target are left behind as orphans.
OffOffEverything stays working.The highest chance of orphan orders filling later.

Two details that catch people:

  • Disabling is not flattening. None of the four combinations closes the account's position. If you disable with a position open, decide on purpose whether to close it (Positions tab > right-click > Close Position) or to keep a stop working for it. [3]
  • OCO pairs may depend on your PC. For the NinjaTrader connection the help guide says most OCO functionality is simulated on your local PC, and for Rithmic that OCO is simulated on your local PC. [4] If you keep exit orders working after a disable, check that when one side fills, the other side is actually cancelled.

Other things that stop a strategy or cancel its orders

Unticking the Enabled box is not the only way a strategy stops. Each of these has its own behavior, so after any of them, look at the Orders and Positions tabs instead of assuming:

  • Order errors. With the default RealtimeErrorHandling.StopCancelClose, a rejected order stops the strategy, cancels its remaining orders and closes its positions. [5]
  • Connection loss, when the On connection loss handling is set to Stop strategy: the strategy stops once the disconnect lasts longer than the delay. [1] See what happens when the internet disconnects.
  • Exit on session close. IsExitOnSessionCloseStrategy (on by default) cancels strategy orders and closes strategy positions at the close of the session, ExitOnSessionCloseSeconds (default 30) before the session end in the strategy's Trading Hours template. [6][7]

A common setup for unattended strategies

Many traders who run strategies unattended check both boxes before they add the strategy row, so a disabled strategy never leaves a stray entry that fills later, and pair that with a rule: whenever a strategy is disabled with a position open, close the position or place a stop by hand. After any disable, look at the Orders tab and the Positions tab before you enable again, and confirm in the Enabling NinjaScript strategy log line that the row itself shows both values as True. Which setup fits you depends on how your strategy exits and how you supervise it.

If you have orders left over already, the orphaned orders guide shows how to find and clear them.

Sources

  1. NinjaTrader 8 help guide, Settings > Strategies
  2. NinjaTrader 8 help guide, Settings
  3. NinjaTrader 8 help guide, Control Center > Positions Tab
  4. NinjaTrader 8 help guide, Where do your orders reside?
  5. NinjaTrader 8 help guide, RealtimeErrorHandling
  6. NinjaTrader 8 help guide, IsExitOnSessionCloseStrategy
  7. NinjaTrader 8 help guide, ExitOnSessionCloseSeconds

General information about NinjaTrader 8 settings, checked against NinjaTrader’s help guide on the date above. Not financial advice. NinjaTrader changes between versions; confirm each setting on your own install.