PDA

View Full Version : Strategy: Monitoring Stop-Loss and Profit Target Orders


NinjaTrader_Josh
02-24-2008, 12:15 AM
Reference sample for NinjaTrader 6.5.XXXX.X or greater.

At times you may have a need to monitor the stop-loss and profit target orders generated by the SetStopLoss(), SetTrailStop() or SetProfitTarget() methods. You can accomplish this by capturing their unique IOrder.Token values as the the OnOrderUpdate() method is called and process them into a collection for future referencing.

The attached reference sample demonstrates the following concepts:

Monitoring stop-loss order states
Monitoring profit target order states

Important methods and properties include:

IOrder (http://www.ninjatrader.com/support/helpGuides/nt7/iorder.htm)
ArrayList (http://msdn.microsoft.com/en-us/library/system.collections.arraylist.aspx)
OrderState

Other methods and properties of interest include:

OnOrderUpdate() (http://www.ninjatrader.com/support/helpGuides/nt7/onorderupdate.htm)
System.Collections (http://msdn.microsoft.com/en-us/library/system.collections.aspx)

Import instructions for NinjaTrader 6.5.XXXX.X or greater:

Download the file contained in this thread to your PC desktop
From the Control Center window, select the menu File > Utilities > Import NinjaScript
Select the downloaded file