NinjaScript diagnostics

3 min read

Why did NinjaTrader ignore my strategy order?

A signal appeared, but the expected order is missing. Follow the signal from your strategy code into NinjaScript Output and read the reason NinjaTrader recorded.

Illustration of a magnifying glass over a paper trace marked “IGNORED.”

Quick answer

Enable TraceOrders in the strategy and open NinjaScript Output from the Control Center’s New menu. Find the call by its time and signal name. If NinjaTrader ignored it, the trace can tell you which rule applied. If the call is missing, add a Print() just before the order method to see whether the strategy reached that line.

Trace one signal from the strategy

TraceOrders is off by default. In the strategy’s OnStateChange() method, set TraceOrders = true inside the State.SetDefaults block. Compile the strategy, then run a fresh instance on a simulated account using the instrument, bar series and settings you want to investigate. If you use a vendor strategy without editable source, ask the author how to enable tracing for your version.

Suppose your entry signal is named Pullback. Inside the entry condition, put Print("Pullback entry reached"); immediately before the existing order-method call. If the marker is missing, print the bar time and the values used by the condition where it is evaluated. That shows which comparison passed or failed on the bar you are checking.

Read the action and the reason together

NinjaTrader’s managed-order examples show three outcomes that can look similar when you are watching for a new order. Match the signal name and timestamp before interpreting a line.

  • An “Entered” line tells you the order method ran. Check the order-state updates to see whether the order became working or was rejected.
  • An “Ignored” line gives a reason. If it names the entry-signal limit, compare EntryHandling and EntriesPerDirection with the entries already counted for that direction.
  • An “Amended” line means NinjaTrader changed a working order. Match the signal and the new price or quantity to that order.

When the marker appears but the trace is missing

Inspect the strategy for an OnOrderTrace() override. An override takes over trace output. If it filters the message or sends it to a file, the usual line can be missing from NinjaScript Output. Have the handler print the timestamp and message while you reproduce the event.

For a submitted order, OnOrderUpdate() reports state changes and rejection details. To establish whether any quantity actually filled, check OnExecutionUpdate() for executions on that order. If you need to send the incident to support, keep the relevant output lines along with the platform log and trace files for that session.

Official sources

Platform recovery

Get an email when Ninja Watchdog recovers your platform

Ninja Watchdog can restart NinjaTrader after a crash and email you a recovery report. Your strategy and NinjaTrader handle the orders.

Try Ninja Watchdog