Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetTrailStop aborts strategy

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

    SetTrailStop aborts strategy

    Hi !
    I have found this problem in one of my strategies. I suppose that the problem is in the trail stop internals (?), since the error is in the sell order. Here attached a false market replay, and the simplified strategy that generates the error. You must set the instrument YM 03-11, and volume chart to 5.

    Code:
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
                SetTrailStop("", CalculationMode.Ticks, 10, false);
                BarsRequired = 1;
    
                CalculateOnBarClose = true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                Print (CurrentBar.ToString() + "-" + Close[0].ToString());
                // Condition set 1
                if (CurrentBar == 16)
                {
                    EnterLong(DefaultQuantity, "");
                }
            }
    No problem, except that the strategy is stopped. Fortunately the position is closed.

    Thanks !
    Attached Files

    #2
    Hi Jonas,

    What settings should I be running on? What type of chart? What interval?
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Default settings. YM 03-11, and volume chart to 5.

      Thanks

      Comment


        #4
        Jonas,

        I am not getting the error you are getting. Instead I get this one which is expected: "Sell stop or sell stop limit orders cannot be placed above the market. Affected Order : Sell 1 Stop @ 12731".
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Yes, in my case the order gets this error also (OK), but the strategy closes itself, this is the problem. I don't send the sell (automatic since I set the Trail Stop in the Initialize method).
          Your strategy remains open? If so I'll look to my settings ...

          Thanks

          Comment


            #6
            No, NT closes out the strategy if any errors like this occurs. This is expected behavior.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Oh. If this is expected behavior, I must work overriding the default methods. I have some strategies that automatically set the stop with the SetTrailStop method. Shame !

              Thanks

              Comment


                #8
                This is expected behavior with any order placement you use. If the order is invalid and is rejected NT will stop the strategy. Reason for this is because from an automated standpoint NT has no idea how you would like it to handle. Does it resubmit? Does it leave it unprotected and continue running? First one, price is still invalid. Second one, is extremely dangerous. As such, NT just stops the strategy after closing all positions to minimize damage.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Yes, it's OK Josh, but I let to NT to place the stop since I have SetTrailStop in the initialize. I don't say the price, I say only the displacement ticks from the fill price. From that moment I understood that it was not my problem: the software will control the exit. I know that it is limited, and if the price is bellow the stop, selling is always OK, because it was my order, and this error (bellow price) maybe would be controlled from the SetTrailStop logic (I don't have created the sell order). When the strategy closes the position is also closed, this is OK, and a security measure. But the strategy closes and the strategy was OK.
                  So I think that the best, as happens in the SetTrailStop case so can also happen with my orders, it is best to handle all my order events for myself.

                  Thanks again !

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  633 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  364 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  567 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  568 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X