OnOrderTrace()

View as Markdown

Definition

An event driven method used for strategies which will allow you to customize the output of TraceOrders.

Warning: Overriding this method will disable the default order tracing that is generated by the NinjaTrader core. It is then up to you to pass the message generated to the NinjaTrader output window using the Print() method. Generally, overriding this method is not required.

Method Return Value

This method does not return a value.

Syntax

You must override the method in your strategy with the following syntax:

protected override void OnOrderTrace(DateTime timestamp, string message)

Method Parameters

ParameterDescription
timestampThe time that the order trace was generated
messageThe message that is generated

Examples

1protected override void OnOrderTrace(DateTime timestamp, string message)
2{
3 // The below print would give us the default tracing
4 Print(string.Format("{0} {1}", timestamp, message));
5
6 // The extended example would also include the instrument fullname from our primary bars object
7 if (BarsArray[0] != null)
8 Print(string.Format("{0} {1} {2}", timestamp, message, BarsArray[0].Instrument.FullName));
9}

Additional Reference Samples

Additional reference code samples are available in the NinjaScript Educational Resources section of our support forum.