Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLongLimit and ExitLongStopMarket order with same entry name

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

    ExitLongLimit and ExitLongStopMarket order with same entry name

    Hi,

    From my strategy, I am placing profit target order using ExitLongLimit and stop order using ExitLongStopMarket by passing the same entry signal name as fromEntrySignal. When the Profit target is filled, the stop order will be closed automatically ? Similarly when the stop order is filled, the profit target will be closed automatically ? OR from my strategy i need to cancel it explicitly . Kindly clarify.

    #2
    Hello nandhumca,

    Thank you for your post.

    Since you are using the fromEntrySignal parameter for the ExitLongLimit and ExitLongStopMarket orders with the same entry signal name, once one of those orders fills and the position is closed the other order will be canceled with the reasoning "Cancelled pending exit order, since associated position is closed."

    For some additional information related to orders and when they are canceled, the default behavior is for an order to be canceled if the conditions to trigger that order are no longer true. Otherwise, there is an option for orders to be live until canceled if the isLiveUntilCancelled bool is set to true in the order method. The following reference sample explains the difference between the two and there is more info about live until canceled orders in the Advanced Order Handling section of the help guide:Please let us know if we may be of further assistance.

    Comment


      #3
      Thanks a lot Emily. I was using isLiveUntilCancelled along with fromEntrySignal. That is was causing dangling order on the opposite side.

      Comment


        #4
        if i place order only with fromEntrySignal and without setting isLiveUntilCancelled and the PT/SL didn't get filled on the same bar, it is getting closed automatically at the end of the bar. I want to this to be in live until either PT/SL hits. Kindly help to achieve on this.

        Comment


          #5
          Hello nandhumca,

          That would be expected, when you do not use IsLiveUntilCanceled on an order that rests at a specific price the order will expire after 1 OnBarUpdate event. You need to keep calling the order method to keep it alive until filled. You can see a sample of that concept in the following strategy builder samples: https://forum.ninjatrader.com/forum/...rategy-builder

          You otherwise need to use IsLiveUntilCanceled if you plan to submit the order one time and wait for it to be filled.

          Comment


            #6
            If i use IsLiveUntilCanceled , how / when to cancel the SL order partially when the PT is part-Filled ? How/when to cancel the SL order fully when the PT is filled Fully ?

            Comment


              #7
              Hello nandhumca,

              The opposing order can be cancelled in OnExecutionUpdate() (or OnOrderUpdate()).

              Below is a link to the ProfitChaseStopTrailExitOrdersExample example which has sample code.
              https://forum.ninjatrader.com/forum/...ing#post802269

              If you want to adjust the quantity after a part fill, this example has sample code.
              Hello, I see in the documentation you have fixed: 15048 Added Adapter, Rithmic Updated Rithmic API to version 11.3.0.0 Can you elaborate on that please? Will OnOrderUpdate() OnExecutionUpdate() and OnPositionUpdate() be called in the expected order?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                If i set IsLiveUntilCanceled= true and an unique value as OCO for both PT and SL , will that work as oco order ? If i set oco for both PT and SL , do I still need to cancel the opposing order ?

                Comment


                  #9
                  One more question . When I tested the order with IsLiveUntilCanceled as per the example you have shared, i am seeing below case where both SL and PT order moved to filled state and in PT order there is -1 remaining order. Is that expected ? how to handle it in code ?



                  Click image for larger version

Name:	image.png
Views:	417
Size:	170.1 KB
ID:	1273111

                  Comment


                    #10
                    Originally posted by nandhumca View Post
                    If i set IsLiveUntilCanceled= true and an unique value as OCO for both PT and SL , will that work as oco order ? If i set oco for both PT and SL , do I still need to cancel the opposing order ?
                    Hello nandhumca,

                    Thank you for your responses.

                    When using Exit() orders in the Managed Approach, setting an OCO value is not an option. OCO is only applied to stops and targets created via Set() methods like SetStopLoss() and SetProfitTarget(). My colleague Chelsea specifically mentioned the ProfitChaseStopTrailExitOrdersExample because this contains logic in OnOrderUpdate() to try and simulate OCO using the Managed Approach and Exit() orders. Please see the logic starting at line 251 with the code comment "// the logic below is to simulate OCO when manually cancelling an order." to see how this was achieved in that example. In your example where both the stop loss and profit target filled with a remaining quantity of -1, I suggest adding Print() statements to your strategy to better understand its behavior and make sure it is behaving as expected. The ProfitChaseStopTrailExitOrdersExample contains Print statements throughout to help explain what actions are being taken so you can understand which parts of the logic are being hit and why. You will need to do something similar in your strategy to understand why both orders were filled so you may adjust your logic to prevent that from happening in the future. Fore more details on using prints to debug your script's behavior:


                    Please let us know if we may be of further assistance.​

                    Comment


                      #11
                      Thanks Emily. What will happen if i cancel a order again which is already cancelled ?

                      Comment


                        #12
                        Can you also please share me a sample code to handler partially filled entry order ? the code reference you have shared above is expecting for the entry order to be completely filled.

                        Comment


                          #13
                          Originally posted by nandhumca View Post
                          Thanks Emily. What will happen if i cancel a order again which is already cancelled ?
                          If you call CancelOrder() for an order that was already canceled in simulation, nothing happens. There is no order to be canceled and no errors come up. The following reference sample shows how to submit stops and targets for partial fills:Please let us know if we may be of further assistance.

                          Comment


                            #14
                            Thanks Emily for the sample one partial filled order. In that sample ExitLongStopMarket and ExitLongLimit are placed multiple times for each part-filled event with same entry signal. The subsequent ExitLongStopMarket and ExitLongLimit with same entry name will be considered as new order or it will be update on existing active order with same entry signal ?

                            Comment


                              #15
                              Originally posted by nandhumca View Post
                              Thanks Emily for the sample one partial filled order. In that sample ExitLongStopMarket and ExitLongLimit are placed multiple times for each part-filled event with same entry signal. The subsequent ExitLongStopMarket and ExitLongLimit with same entry name will be considered as new order or it will be update on existing active order with same entry signal ?
                              The subsequent stop and target orders (ExitLongStopMarket and ExitLongLimit) will be updated in the case of partial fills. Each time additional contracts are filled, you will see a status of "Change submitted" for the MyStop and MyTarger orders on the Log tab of the Control Center in order to change the quantity of the orders. This is something you may test on your end as well to observe how the orders behave, and you could even print out the OnOrderUpdate() information or enable TraceOrders as a debugging tool in order to better understand the strategy's behavior.

                              Please let us know if we may be of further assistance.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Today, 05:17 AM
                              0 responses
                              50 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              126 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              69 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              42 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              46 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X