Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

OnOrderUpdate and OnExecutionUpdate

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_Jim
    replied
    Hello guidoisot,

    No, you can test the strategy as is in the Strategy Analyzer to observe that it can be backtested and OnOrderUpdate and OnExecutionUpdate can be used when backtesting.

    The suggestion to skip historical processing is simply for testing so you can enable the strategy and know that it has started flat.

    Leave a comment:


  • guidoisot
    replied
    Originally posted by NinjaTrader_Jim View Post
    ... can be used to quickly test your logic from a flat position.
    you mean either in real time or better in simulated feed since the latter can be run faster than real time.
    So does this imply that OnOrderUpdate and OnExecutionUpdatecannot be used in backtesting?
    and neither in market replay?
    thx

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Hello guidoisot,

    When we enable a script, it first processes historical data and then it processes realtime data.

    If you want to skip historical processing, you can check if the current state is State.Historical, and then call return. This will effectively have the script always start flat and can be used to quickly test your logic from a flat position.

    I have attached a screenshot showing this code added in OnBarUpdate.
    Attached Files

    Leave a comment:


  • guidoisot
    replied
    Originally posted by NinjaTrader_Jim View Post
    ... I may also suggest testing with if (State == State.Historical) return; added to the script's OnBarUpdate method, and with prints added in OnOrderUpdate and OnExecutionUpdate to print out the Order and Execution when these updates occur. This will help to visualize when these events occur and how they can be used.
    please could you elaborate further on this ... for ex show a sample or a screencast. I do not understand how to use if (State == State.Historical) return; where exactly to insert it and what info it is going to tell.
    thx

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Hello horace chow,

    OnOrderUpdate will iterate when an order is submitted, accepted, working and filled.

    OnExecutionUpdate will iterate when an order is executed (filled or partial filled.)

    These are separate events than market data events which will update OnBarUpdate/OnMarketData.

    You can check the SampleOnOrderUpdate strategy for further direction on using these methods. I may also suggest testing with if (State == State.Historical) return; added to the script's OnBarUpdate method, and with prints added in OnOrderUpdate and OnExecutionUpdate to print out the Order and Execution when these updates occur. This will help to visualize when these events occur and how they can be used.

    SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

    We look forward to assisting.

    Leave a comment:


  • bltdavid
    replied
    Originally posted by horace chow View Post
    So can you explain when does OnOrderUpdate and OnExecutionUpdate runs? which runs when the tick increase or decrease and which would run when the order is submitted
    What does when tick increase or decrease mean?

    After an entry order is submitted you would soon see OnOrderUpdate called for the
    StateChange events of that order as it eventually goes to Working -- or to Accepted.

    When the order is executed at the exchange, OnOrderUpdate is called again to reflect
    the StateChange to Filled (or PartFilled). Right after this, you will see OnExecutionUpdate
    is called.

    If by tick increase or decrease you mean manually adjusting an open order up or
    down by 1 tick using +/- buttons in Control Center -- yes, you will receive an OnOrderUpdate
    event in your strategy each time you adjust the StopPrice or LimitPrice of a standing
    order -- even when this is done manually via +/- buttons in the Control Center Orders tab.
    Last edited by bltdavid; 05-27-2020, 06:24 PM.

    Leave a comment:


  • horace chow
    replied
    So can you explain when does OnOrderUpdate and OnExecutionUpdate runs? which runs when the tick increase or decrease and which would run when the order is submitted

    Leave a comment:


  • bltdavid
    replied
    They are not mutually exclusive.

    OnOrderUpdate (usually) runs first, this callback lets you inspect all OrderState changes.

    OnExecutionUpdate runs second (if necessary) and only when the OrderState is Filled or PartFilled.

    You may well see both of these fire in quick succession.

    Leave a comment:


  • horace chow
    started a topic OnOrderUpdate and OnExecutionUpdate

    OnOrderUpdate and OnExecutionUpdate

    I was wondering for the OnOrderUpdate() and the OnExecutionUpdate, when does it run?

    " 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 OnExecutionUpdate() 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."

    - For the OnOrderUpdate, it runs whenever an order changes, does it mean like for example when the ticks increase or decrease, or in terms of change as if the order has been filled and canceled?
    - For the OnExecutionUpdate, it said execution or fill on your orders, so does it run whenever a contract has been submitted and whenever the contract hits a profit target and stop loss, if so, how do I implement it in a way where there is a specific stop loss or profit target.

    The definition is very unclear and I want to have a more defined definition. Thanks

Latest Posts

Collapse

Topics Statistics Last Post
Started by arvidvanstaey, Today, 02:19 PM
3 responses
9 views
0 likes
Last Post NinjaTrader_Zachary  
Started by jordanq2, Today, 03:10 PM
2 responses
8 views
0 likes
Last Post jordanq2  
Started by traderqz, Today, 12:06 AM
10 responses
18 views
0 likes
Last Post traderqz  
Started by algospoke, 04-17-2024, 06:40 PM
5 responses
47 views
0 likes
Last Post NinjaTrader_Jesse  
Started by mmckinnm, Today, 01:34 PM
3 responses
7 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X