Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods.
The OnOrderUpdate() method is updated whenever the state of an order changes which allows you to submit and control your stop-loss and profit target orders the instant your entry order is filled.
The OnExecution() method is updated whenever you receive an execution or a fill on your orders. This method provides you the fastest possible submission of protective orders. Utilizing the increased granularity provided in these advanced methods can be advantageous to you by providing you with maximum control of how your stop-loss and profit target orders behave.
Key concepts in this example:
- Submitting live-until-cancelled entry orders
- Modifying stop-loss order to breakeven after a certain amount in profit
Important related documentation:
NinjaTrader 8
- Order
- Execution
- OnOrderUpdate()
- OnExecutionUpdate()
- ExitLong()
- ExitLongLimit()
- ExitLongMIT()
- ExitLongStopLimit()
- ExitLongStopMarket()
- ExitShort()
- ExitShortLimit()
- ExitShortMIT()
- ExitShortStopLimit()
- ExitShortStopMarket()
- SetStopLoss()
- SetProfitTarget()
- SetTrailStop()
NinjaTrader 7
- IOrder
- IExecution
- OnOrderUpdate()
- OnExecution()
- ExitLong()
- ExitLongLimit()
- ExitLongStop()
- ExitLongStopLimit()
- ExitShort()
- ExitShortLimit()
- ExitShortStop()
- ExitLongStopLimit()
- SetStopLoss()
- SetProfitTarget()
- SetTrailStop()
Import instructions:
NinjaTrader 8
- Download the file contained in this thread to your PC desktop
- From the Control Center window, select the menu Tools > Import > NinjaScript
- Select the downloaded file
NinjaTrader 7
- 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 and click Import.