Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop & Restart of Strategy Cancels Existing orders, SyncAccountPosition = false

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

    Stop & Restart of Strategy Cancels Existing orders, SyncAccountPosition = false

    Situation:
    When restarting strategy, existing working orders left when strategy was disabled are cancelled, even though SyncAccountPosition = false and strategy option box "Cancel exit orders when a strategy is disabled" is not checked. This is leaving orders without protective stop losses and targets.

    Description:
    Strategy position is long or short. Strategy enable box is then unchecked in command center. Working/accepted orders for stop and profit target are still active.

    When the strategy re-enabled via the checkbox in the command center, the working orders are cancelled.

    Question:
    How do I keep my targets and stop orders in place on strategy reactivation?
    Last edited by dojidubbs; 09-08-2011, 10:33 AM. Reason: added text to specify exit orders option

    #2
    Hello Dojidubbs,

    There is not a supported option to prevent these stops and targets from canceling when the strategy reactivates. What happens at this point is your pending orders are canceled, recalculated and resubmitted based off the historical data at the point the strategy is re-enabled.

    For more details on this item and some workarounds that are available, please see the following thread:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks for the link. It didn't show up by searching "strategy cancel orders restart", perhaps because "strategy" is incorrectly spelled in the title, not sure. Anyway...

      I am really struggling to wrap my head around restarting a strategy. I'd like to outline a situation and have you verify I am correct to see if I understand it correctly. I appreciate your help and understanding during my period of brain denseness

      The examples below assumes long entry on ES at 1190.00, 8 tick stoploss, 8 tick profit target, strategy was in a position, Strategy is reloaded via F5 on the chart during the same bar. COBC=true. My thoughts are based on this one particular order/situation only.





      Wait until flat before executing live, Sync account position = false
      • Existing SL and PT orders will be canceled
      • Account position will remain untouched, and is no longer associated with the reactivated strategy
      • Strategy orders are "executed virtual" until strategy goes flat
      Wait until flat before executing live, Sync account position = true
      • Existing SL and PT orders will be cancelled
      • Account position will be flattened immediately with a market order
      • Strategy orders are "executed virtual" until strategy goes flat
      Immediately submit live working historical orders, Sync account position = false
      • Existing SL and PT stay in place, since they map exactly to strategy orders
      • Account position remains untouched, since it assumes account is in sync
      • Strategy begins to manage existing position of long at 1190, effectively my open account position and will stop out at 1188 or close with a limit order at 1192 depending on market movement
      Immediately submit live working historical orders, Sync account position = true
      • Existing SL and PT stay in place, since they map exactly to strategy orders
      • Account position remains untouched, since account and strategy are both 1L
      • Strategy begins to manage existing position of long at 1190, effectively my open account position and will stop out at 1188 or close with a limit order at 1192 depending on market movement

      Comment


        #4
        Hello dojidubbs,

        Thanks for the detailed reponse here.

        Yes, that is mostly true. It's also important to understand that the strategy will compare the new historical run with the actual strategy run in order to sync up any of your previous strategy orders.
        "A previously generated order is considered to match an active strategy order when the order action, order type, quantity, limit price, and stop price are exactly identical."
        MatthewNinjaTrader Product Management

        Comment


          #5
          Thanks for the quote. I saw that in the documentation, just trying to take this one step at a time, so that is why I framed the example specifically with an immediate refresh, and nothing that would move the stoporder/profit target stops. I have questions on that situation, but would like to hold off on that point for now.

          So to continue on.....

          What happens when I run a strategy Immediately submit live working historical orders (doesn't make a difference what sync account position is set to) is::
          • Existing SL and PT stay in place, since they map exactly to strategy orders
          • When the next bar opens after strategy is reactivated, the SL and PT are cancelled due to be expired.
          Are the orders cancelling on the next bar expected behaviour? I don't see anything in the Syncing Account Positions help that indicates the orders will be cancelled.

          Comment


            #6
            Hello,

            It is expected that they get cancelled then immediately resubmitted. The reason this occurs is so the strategy can take control of the stop loss and profit target orders.

            However if the stops are expiring and no longer being resubmitted. Then something else is going on and make likely coding issue.

            Have you tried running TraceOrders = true?

            I look forward to assisting you further.
            BrettNinjaTrader Product Management

            Comment


              #7
              Brett.

              No they do NOT get cancelled and resubmitted immediately. It appears in my testing that only happens unless they do not match exactly, which they do. I am basiing this on the seeing the timestamp of the orders do not change.

              Yes, I have run trace orders, Here is the message in the output:
              9/9/2011 8:30:00 AM Cancelled expired order: BarsInProgress=0: Order='ad52b38f96d44246b89263c3e85c39cc/Sim101' Name='Stop loss' State=Accepted Instrument='ES 12-11' Action=Sell Limit price=0 Stop price=1153.75 Quantity=1 Strategy='testofstopnottriggering' Type=Stop Tif=Gtc Oco='NT-00622-1579' Filled=0 Fill price=0 Token='ad52b38f96d44246b89263c3e85c39cc' Gtd='12/1/2099 12:00:00 AM'
              I'm more than happy to do or provide anything you need to show you the situation, be it remote assist, logs, etc.
              Last edited by dojidubbs; 09-09-2011, 09:34 AM. Reason: removed english error

              Comment


                #8
                Hello,

                I'm not sure I know what you mean by "it appears in my testing that only happens unless they do not match exactly, which they do."

                Do they match or not? Can you expand on what you were saying here?

                Do you mean that sometimes they resubmit after canceling, or they never resubmit and they are only canceled?
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Happy to expand, I know I'm not the greatest writer and communication via forums has its challenges
                  It is expected that they get cancelled then immediately resubmitted. The reason this occurs is so the strategy can take control of the stop loss and profit target orders.
                  In my testing, orders as far as I can see are not always cancelled and resubmitted upon strategy reactivation. If there is an exact match, this appears not to be the case. In my case, immediately after strategy reactivation., sometimes they match, sometimes they do not, depending on the actual fill price achieved.

                  Example: With 2pt stop, 2pt loss, if I fill without slippage, the orders don't resubmit. If I have slippage on the fill, the orders will be cancelled and resubmitted, based upon history fill price, not actual price.

                  The point above was just information sharing in case it was related to the issue and not the issue. Sorry for clouding the matter.

                  Issue is as stated in post #5:
                  When the next bar opens after strategy is reactivated, the SL and PT are cancelled due to be expired.
                  In all cases I have working orders for stop and profit working upon immediate stategy reactivation. The issue is when the next bar opens after the stategy is activated, the SL and PT are cancelled. So, yes, the stops are expiring and no longer being resubmitted.

                  Comment


                    #10
                    Hello,

                    If the order is not being resubmitted this would tell me the strategy position is most likely flat or the strategy is not coded to submit a stop loss order.

                    Do you see what the strategy position is reported as when this occurs?
                    BrettNinjaTrader Product Management

                    Comment


                      #11
                      The strategy has the SL and PT being set in the Initialize section.

                      The strategy position is "Long" at the time of the order being cancelled.

                      Comment


                        #12
                        ok and lastly what are your settings for running the strategy.

                        Wait until flat before running live?
                        BrettNinjaTrader Product Management

                        Comment


                          #13
                          No as stated in post #5, Immediately submit live working historical orders

                          Comment


                            #14
                            Hello,

                            Understood.

                            In this case would not be expected.

                            Do you have a sample or test strategy you can send me to support at ninjatrader dot com ATTN: Brett so that I may test this on my end and see what specifically is going on with your code.

                            I look forward to assisting you further.
                            .
                            BrettNinjaTrader Product Management

                            Comment


                              #15
                              Yep. Strategy attached to this post and sent via email.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              672 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              379 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              111 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              575 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              582 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X