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

Critical: logic of submission StopLoss orders

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

    Critical: logic of submission StopLoss orders

    Ninjas, I got a confusion here trying to know which situation is the correct.

    Reading the part regarding when to submit StopLoss orders ,using either OnOrderUpdate() or OnExecution() , like is shown on the help guide:


    I'm kind of confused with this:

    CRITICAL: If you want to drive your strategy logic based on order fills you must use OnExecution() instead of OnOrderUpdate(). OnExecution() is always triggered after OnOrderUpdate(). There is internal strategy logic that is triggered after OnOrderUpdate() is called but before OnExecution() that can adversely affect your strategy if you are relying on tracking fills within OnOrderUpdate().
    and this:

    If you are relying on the OnOrderUpdate() method to trigger actions such as the submission of a stop loss order when your entry order is filled ALWAYS reference the properties on the IOrder object passed into the OnOrderUpdate() method.
    Which method is the right for submit Stop orders?

    #2
    Hello pstrusi,

    Thanks for your note.

    The first message is letting you know that OnExecution will always be triggered after OnOrderUpdate. It is also advising that if you are waiting for an order to be filled, to use OnExecution instead of OnOrderUpdate to execute code at that time.

    The second message is saying that if you are using OnOrderUpdate(IOrder order) always use the order IOrder object.

    For example if you have an entry order associated to an IOrder handle.
    private IOrder myEntry = null;
    myEntry = EnterLong();

    In on order update, check that the order object is equal to the myEntry object. But use the order object to check the state of the order.

    protected override void OnOrderUpdate(IOrder order)
    {
    // check if myEntry equals order
    if (myEntry != null && myEntry == order)
    {
    // check the order state of the order object
    if (order.OrderState == OrderState.Cancelled)
    {
    // execute code
    }
    }
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by pstrusi View Post
      Ninjas, I got a confusion here trying to know which situation is the correct.

      Reading the part regarding when to submit StopLoss orders ,using either OnOrderUpdate() or OnExecution() , like is shown on the help guide:


      I'm kind of confused with this:



      and this:



      Which method is the right for submit Stop orders?
      I read that to mean that the preferred and recommended place is in OnExecution(), but if, for any reason, you think that you MUST use OnOrderUpdate(), then make sure that you use IOrders.

      Comment


        #4
        Hey koganam,

        I agree with the first part, where the preferred place to place to execute code after a fill is in the OnExecution.

        However, for the second part, I think this is insisting that the OnOrder update order IOrder object is used instead of the handle associated IOrder object.

        ALWAYS reference the properties on the IOrder object passed into the OnOrderUpdate() method.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hey koganam,

          I agree with the first part, where the preferred place to place to execute code after a fill is in the OnExecution.

          However, for the second part, I think this is insisting that the OnOrder update order IOrder object is used instead of the handle associated IOrder object.
          Not sure of the difference: I think that is what I said. No? "... then make sure that you use IOrders."

          Comment


            #6
            Hi koganam,

            :-) In a way yes, you are correct.

            I was just meaning that both the handle associated with the order and the order variable that is supplied to the OnBarUpdate method will both be IOrders.

            Specifically, I believe this is saying to use the OnBarUpdate supplied IOrder (order variable) and not the IOrder the entry is set to (myEntry).

            They will both be IOrders though.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jclose, Today, 09:37 PM
            0 responses
            4 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,413 views
            0 likes
            Last Post Traderontheroad  
            Started by firefoxforum12, Today, 08:53 PM
            0 responses
            10 views
            0 likes
            Last Post firefoxforum12  
            Started by stafe, Today, 08:34 PM
            0 responses
            10 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by sastrades, 01-31-2024, 10:19 PM
            11 responses
            169 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X