Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Confused

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

    Confused

    I am confused about where I should handle entry orders

    Here is an example given in the forum by NT

    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    {
    // Handle entry orders here. The entryOrder object allows us to identify that the order
    //that is calling the OnOrderUpdate() method is the entry order.
    // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
    // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting


    And this in the NT reference examples

    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {
    // Assign entryOrder in OnExecutionUpdate() to ensure the assignment occurs when expected.
    // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting
    if (execution.Order.Name == "myEntryOrder" && execution.Order.OrderState == OrderState.Filled)
    entryOrder = execution.order;​

    So which is it - or are they interchangeable? Or am I missing something?
    thanks

    #2
    Hello Mindset,

    Thanks for your notes.

    OnOrderUpdate() is called each time an order managed by a strategy changes state. An order will change state when a change in order quantity, price or state (working to filled) occurs. This is where entry orders should be handled.

    From the SampleOnOrderUpdate reference sample: "The entryOrder object allows us to identify that the order that is calling the OnOrderUpdate() method is the entry order. Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected. This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting"

    OnExecutionUpdate() is an event-driven method that is called on an incoming execution of an order managed by a strategy. An execution is another name for a fill of an order. 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.

    From the SampleOnOrderUpdate reference sample: "We advise monitoring OnExecution to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate() which ensures your strategy has received the execution which is used for internal signal tracking.​"

    Here is a documented reference sample from the help guide demonstrating using OnOrderUpdate() and OnExecutionUpdate() for handling orders: https://ninjatrader.com/support/help...and_onexec.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      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.

      Sorry to bang on about this but I can submit protective orders in either method? but Execution is fastest but control is better in OnOrderUpdate?
      I have not been using OnOrderUpdate - I use ExecutionUpdate instead - but I am starting to think I may be incorrect.
      I stumbled across this solely because my OnExecutionUpdate is getting too big and unwieldly. It still works and performs nicely but still if it's not best practice I would rather change.
      I should add I Am using the unmanaged approach so it's a little more complex.

      Comment


        #4
        Hello Mindset,

        Thanks for your notes.

        Yes, that is correct. You could submit protective orders from either OnOrderUpdate() or OnExecutionUpdate().

        We recommend submitting protective orders in OnExecutionUpdate() as best practice since this is the fastest possible way to submit protective orders. Further, OnExecutionUpdate() is called after OnOrderUpdate() which ensures your strategy has received the execution which is used for internal signal tracking.

        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sastrades, Today, 09:24 PM
        0 responses
        2 views
        0 likes
        Last Post sastrades  
        Started by techbid, 03-21-2025, 12:16 PM
        1 response
        13 views
        0 likes
        Last Post techbid
        by techbid
         
        Started by laketrader, 03-10-2025, 07:20 AM
        7 responses
        68 views
        0 likes
        Last Post laketrader  
        Started by juletjak, Today, 07:37 PM
        0 responses
        3 views
        0 likes
        Last Post juletjak  
        Started by stafe, 03-10-2025, 04:46 PM
        5 responses
        60 views
        0 likes
        Last Post MiCe1999  
        Working...
        X