• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Does partial fill canceling OCO?

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

    Does partial fill canceling OCO?

    Hello

    If one of OCO orders partial filled - what happened after?
    Does it take effect on other OCO orders?

    What if 2 protective OCO orders working for long position of 5 lots.
    Then, tatget order partial filled with 3 lots.
    Then price drop deep down and stop order filled.
    What would be result?

    I suppose 2 lots short position will remain.
    Isn’t it?
    Last edited by fx.practic; 05-28-2018, 02:39 PM.

    #2
    Hello fx.practic,

    Thank you for your post.

    If you are using the SetStopLoss and SetProfitTarget options then the adjustments to the order quantity will be automatic and appropriate.

    If you are using Exit methods such as ExitLongLimit or ExitShortStopMarket and do not specify a quantity in their overloads then they too will adjust automatically.

    If you are using the Unmanaged Order Approach then you need to implement logic to handle the partial fills and adjust the orders.

    For information on the Order methods and Approaches please visit the following link: https://ninjatrader.com/support/help...er_methods.htm

    Please let me know if you have any questions.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      I mean unmanaged approach.

      What is correct way to handle partial fills of protective OCO orders (profit target and stop loss)?

      I suppose, strategy should monitor OCO orders partial executions in OnExecutionUpdate() method and change all OCO-bounded orders on each execution.Order.OrderState.PartFilled.

      Is this right?
      Last edited by fx.practic; 05-28-2018, 03:13 PM.

      Comment


        #4
        Hello fx.practic,

        Thank you for your response.

        You are correct. You would use OnExecutionUpdate() and the execution.Order properties.

        Please let me know if you have any questions.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          Thank You.

          Comment


            #6
            Have once more OCO-related question.

            In this article we can see example of how to handle umnanaged protective orders:

            PHP Code:
            protected override void OnExecutionUpdate()
            {
                
            // Reset our stop order and target orders' Order objects after our position is closed.
                
            if ((stopOrder   != null && stopOrder   == execution.Order) || 
                    (
            targetOrder != null && targetOrder == execution.Order))
                {
                    if (
            execution.Order.OrderState == OrderState.Filled ||
                        
            execution.Order.OrderState == OrderState.PartFilled)
                    {
                        
            stopOrder null;
                        
            targetOrder null;
                    }
                }




            Keeping in mind my very first post in this thread want to ask: why sample script not updating OCO-pair on OrderState.PartFilled of protective orders ?
            Last edited by fx.practic; 05-29-2018, 02:12 PM.

            Comment


              #7
              Hello fx.practic,

              Thank you for your response.

              I may not fully understand your latest inquiry. Do you have a question on the sample you linked?
              Patrick H.NinjaTrader Customer Service

              Comment


                #8
                I mean, what if one protective OCO order (say, profit target) will be partial filled, and then price will move to counterpart OCO protective order (say, stop loss).

                If not to adjust stop loss price - after profit target order partial filled - stop loss will reverse position.
                And new position quantity will be (initial_lot_size - part_filled_lot_size).

                Am I right?
                Last edited by fx.practic; 05-30-2018, 03:17 AM.

                Comment


                  #9
                  Hello fx.practic,

                  Thank you for your response.

                  If you are using the Unmanaged Order Approach then you need to handle these types of items in your code.

                  The sample you refer to is specifically for the Managed Order Approach. This means the Exit order methods will adjust their quantity appropriately and automatically as they are in the Managed Order Approach.

                  Please let me know if you have any questions.
                  Patrick H.NinjaTrader Customer Service

                  Comment


                    #10
                    Could You, please, to inspect this sample and to give Your opinion: is this right place and right safe and guaranteed way to update protective orders on partial fills?

                    (It looks working on historical market replay)
                    (I mean Umnanaged approach)


                    PHP Code:
                    OnExecutionUpdate()
                    {
                        if( 
                    execution.Order.Name == Take_Profit_Name )
                        {
                            
                            if( 
                    Take_Profit_Order != null     &&     Take_Profit_Order == execution.Order) )
                            {
                                if( 
                    execution.Order.OrderState == OrderState.PartFilled ) &&
                                    
                    Stop_Loss_Order != null && 
                                    !
                    Order.IsTerminalStateStop_Loss_Order.OrderState ) &&                                                                
                                    
                    execution.Order.Quantity != Stop_Loss_Order.Quantity     
                                        
                                        
                    ChangeOrderStop_Loss_Orderexecution.Order.QuantityStop_Loss_Order.LimitPriceStop_Loss_Order.StopPrice );
                                }
                            }
                        }

                    Last edited by fx.practic; 05-31-2018, 03:36 AM.

                    Comment


                      #11
                      Hello fx.practic,

                      Thank you for your response.

                      Your code is correct. You can test this on the Sim101 account and set the simulator to enforce partial fills by going to the NinjaTrader Control Center > Tools > Options > Trading > Simulator > Enforce partial fills > OK.

                      Please let me know if you have any questions.
                      Patrick H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by rudccv, Today, 08:42 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post rudccv
                      by rudccv
                       
                      Started by Newtrader101, Today, 03:54 PM
                      1 response
                      17 views
                      0 likes
                      Last Post NinjaTrader_ShawnB  
                      Started by williamzz, Today, 03:28 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post williamzz  
                      Started by Robert87, Today, 11:07 AM
                      0 responses
                      14 views
                      0 likes
                      Last Post Robert87  
                      Started by phta123, Today, 10:24 AM
                      0 responses
                      17 views
                      0 likes
                      Last Post phta123
                      by phta123
                       
                      Working...
                      X