TraceOrders is a useful property when debugging the behavior of your orders. With the use of this property, you can track orders placed, amended, and cancelled. The traces displayed in the NinjaScript Output window will provide meaningful information for diagnosis when NinjaTrader ignores, changes or cancels orders when various strategy order methods are called.
To enable TraceOrders, add this line into the Initialize() method of your NinjaScript strategy:
Trace output examples:
This trace is outputted when we place an entry order. It tells us all the pertaining properties of our order as well as the time it was submitted.
This trace tells us that a previously submitted order was modified instead of submitting a completely new order.
This trace provides the reason why our stop-loss order was ignored.
This trace tells us that our stop-loss order was cancelled because its corresponding position was already closed by another order.
These examples illustrate the most common traces you will run across. They are mostly useful in determining the reason your orders are not submitted or cancelled. TraceOrders will only show you what is happening under the hood when you submit orders, but it will not tell you what happens after the order is submitted. To determine the behavior of your orders after submission you will need to look into your NinjaTrader trace logs. You can view those either through the "Log" tab on the "Control Center" or from the trace folder in My Documents\NinjaTrader 7\trace\.
For more information on how to debug your NinjaScript please review the Debugging tip.