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:
    http://www.ninjatrader.com/support/h...ission_tab.htm

    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:
      http://www.ninjatrader.com/support/h...ission_tab.htm

      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 MSerag, Today, 01:14 AM
            0 responses
            1 view
            0 likes
            Last Post MSerag
            by MSerag
             
            Started by JoycewAustea, Today, 12:36 AM
            0 responses
            2 views
            0 likes
            Last Post JoycewAustea  
            Started by cls71, Today, 12:33 AM
            0 responses
            6 views
            0 likes
            Last Post cls71
            by cls71
             
            Started by BobyGill, 03-27-2023, 05:44 AM
            68 responses
            642 views
            1 like
            Last Post EB Worx
            by EB Worx
             
            Started by 1001111, 06-07-2020, 10:42 AM
            13 responses
            324 views
            0 likes
            Last Post LeonK
            by LeonK
             
            Working...
            X