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.

Orphaned orders in NinjaTrader after a strategy is disabled

Short answer: an orphaned order is a working order that no running strategy is managing any more. It usually comes from a strategy that was disabled, crashed or lost its connection while it had orders out. It matters because it can fill later, sometimes hours later, and open a position that has no stop and nothing watching it.

How orphans happen

  1. Cancel-on-disable is off. If Cancel entry orders when a strategy is disabled or Cancel exit orders when a strategy is disabled is unchecked (Control Center > Tools > Settings > Strategies), those orders stay working after a disable. [1] NinjaTrader copies these values into a strategy row when the row is added, so a row added while they were unchecked can keep them off after you check them; the row's own values are printed in the Enabling NinjaScript strategy log line. The settings guide walks through each combination.
  2. The cancel could not reach the broker. A cancel is a message to the broker. If the strategy stopped while the connection was down, NinjaTrader could not deliver it at that moment. Check the Orders tab after every reconnect.
  3. One side of a bracket filled and the other did not get cancelled. For the NinjaTrader connection most OCO functionality is simulated on your local PC, and for Rithmic OCO is simulated on your local PC. [2] If your PC was offline or NinjaTrader was closed when the stop or target filled, the other side can be left working.
  4. The strategy's code stopped with an error. When a strategy hits an unhandled error, NinjaTrader reports it in the Log tab and the strategy stops. Whether its orders were cancelled depends on how it stopped, so check the Orders tab rather than assuming.
  5. Orders placed outside the strategy. Chart Trader orders or ATM brackets on the same account are not the strategy's orders, and disabling the strategy does not touch them.

When a strategy stops, its positions can stay open without stops, and a leftover limit order can keep sitting in the book. An orphan stays until someone cancels it or it fills.

How to find them

  1. Open the Control Center Orders tab and use Filter By Account to show only the account in question. [3]
  2. Look at orders in the Working or Accepted state; those reside at the broker. TriggerPending orders are held on your PC. [2]
  3. For each one, ask: is a strategy that is running right now managing this order? Is there an open position it belongs to? A stop with no position behind it, or an entry from a disabled strategy, is an orphan.
  4. Compare with your broker's own web platform. NinjaTrader shows the orders it knows about; the broker shows what it holds.

How to clear them without breaking something else

  • Cancel Order (right-click on the order in the Orders tab) cancels just that order. [3] This is the careful option.
  • Cancel All Orders cancels all working orders, including the protective stop of any position that is still open. [3] Use it only when the account is flat or you mean to remove every stop.
  • Flatten Everything (right-click in the Positions tab) "flattens all open positions and cancels all working orders". [4]

After cleaning up, confirm the account is flat or protected the way you intend before you enable a strategy on that account again.

How to prevent them

  • Check both cancel-on-disable boxes before you add the strategy row (an existing row keeps the values it was added with), and close any open position yourself when you disable a strategy. [1]
  • Use Exit on session close (IsExitOnSessionCloseStrategy, on by default) so strategy orders are cancelled and positions closed at the session end in your Trading Hours template. [5]
  • Before re-enabling after a restart, check the Positions and Orders tabs, and know what your Start behavior does: Wait until flat cancels prior strategy-generated orders and trades virtually until the strategy's own position is flat. [6]
  • Make a routine of opening the Orders tab every morning and every time you disable a strategy.

Sources

  1. NinjaTrader 8 help guide, Settings > Strategies
  2. NinjaTrader 8 help guide, Where do your orders reside?
  3. NinjaTrader 8 help guide, Control Center > Orders Tab
  4. NinjaTrader 8 help guide, Control Center > Positions Tab
  5. NinjaTrader 8 help guide, IsExitOnSessionCloseStrategy
  6. NinjaTrader 8 help guide, Syncing Account Positions (Start behavior)

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.