NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Educational Resources > Reference Samples

Reference Samples Official NinjaScript reference code samples

Reply
 
Thread Tools Display Modes
Old 05-08-2008, 01:42 AM   #1
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default Strategy: Using OnOrderUpdate() and OnExecution() methods to submit protective orders

Reference sample for NinjaTrader 6.5.XXXX.X or greater.

The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. 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.

This reference sample demonstrates the following concept:
  • Submitting live-until-cancelled entry orders
  • Modifying stop-loss order to breakeven after a certain amount in profit
Important methods and properties used include:Other methods and properties of interest include:Import instructions for NinjaTrader 6.5.XXXX.X or greater:
  1. Download the file contained in this thread to your PC desktop
  2. From the Control Center window, select the menu File > Utilities > Import NinjaScript
  3. Select the downloaded file
Attached Files
File Type: zip SampleOnOrderUpdate.zip (2.1 KB, 224 views)
File Type: zip SampleOnOrderUpdate_NT7.zip (2.2 KB, 1039 views)
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error on calling the 'OnOrderUpdate' method for strategy 'maslope': Object reference scriabinop23 General Programming 4 01-24-2008 02:20 PM
Can't Submit an Exit Order yeneuro Miscellaneous Support 10 10-08-2007 08:23 AM
Who can supply "ATM Strategy Stop Target methods" Jenny Strategy Development 5 06-13-2007 06:54 AM
ATM Strategy Stop Target methods theperm Strategy Development 9 05-21-2007 03:53 PM


All times are GMT -6. The time now is 01:06 AM.