Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to change order

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

    #16
    Hello bcomas,

    I have added your vote.

    This can happen with volatility, and if you would like to move forward in the meantime, I suggest adding functionality with RealtimeErrorHandling set to IgnoreAllErrors, and then to handle the order error in OnOrderUpdate.

    If you need help setting that up, I would then suggest opening a new thread on the topic.

    Comment


      #17
      Hello Jim,

      So using SetTrailingStop (the set method issue in my case) to override NT messages from the broker like (LiveAccount, Cannot change order 'xxxxxxxxxxx' because current order values already match. affected Order: BuyToCover 1 StopMarket @ 15504.25) when the market is moving fast , the following code into OnBarUpdate can remove popouts?
      Or is impossible to override it....

      Code:
       protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice,
      int quantity, int filled, double averageFillPrice,
      Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
      {
      if (order.Name == "[B]Trail stop[/B]")
      {
      if (error == [B]ErrorCode.UnableToChangeOrder[/B])
      {
      Print("Order change failed, IgnoreAllErrors.");
      
      [B]return;[/B]
      }
      }
      }
      Thanks!

      Comment


        #18
        Hello bcomas,

        As long as you have RealtimeErrorHandling set to IgnoreAllErrors, your code will keep the strategy running in the case of a UnableToChangeOrder Order Error on the Trail stop.

        We should note that the error could also be seen from being unable to change an order that is in the process of filling or cancelling, but this may also be a context that you could simply do nothing without harm. If you wanted to differentiate those cases from "values already match," you could check the comment parameter OnOrderUpdate when the error is received if you want to run different logic based on the native error. I can't easily set up a test to reproduce the expected message from the comment, and this would be different depending on your broker, so I would suggest printing or logging the comment parameter before trying to customize logic with it.

        Finally, keep in mind that all order errors will be ignored including rejections. If you want to still have the default Stop Cancel Close behavior for other order errors or rejections you could add snippet like the following after your "Ignore UnableToChangeOrder on Trail stop code"

        Code:
        if(error != ErrorCode.NoError || orderState == OrderState.Rejected)
            CloseStrategy();
        CloseStrategy() - https://ninjatrader.com/support/help...sestrategy.htm

        Comment


          #19
          Hello Jim,

          Many thanks for your help.

          Is there some solution to override the attached pop out from Ninjatrader Brokerage broker every time my auto strategy is trailing in the short side with the standard NT SetTrailing() in live trading?

          I will apreciate some example if is possible..

          Bernard
          Attached Files

          Comment


            #20
            Hello bcomas,

            The solution is the same as I described in post #18. Differentiating the the exact verbiage from the "values already match" UnableToChangeOrder error vs. other UnableToChangeOrder errors would involve printing out the comment parameter of OnOrderUpdate.

            Code:
            protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice,
                int quantity, int filled, double averageFillPrice,
                Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
            {
                if (error == ErrorCode.UnableToChangeOrder)
                    Print(comment);
            }

            Comment


              #21
              Hello Jim,

              The exact verbiage printed is : Cannot change order 'xxxxxxxxxxx' because current order values already match.

              How is possible override the pop out message if the order is diferent every message?

              Thanks!

              Comment


                #22
                Hello bcomas,

                You can consider using String.Contains from the comment string:

                Code:
                f(order.Name == "Trail stop" && error == ErrorCode.UnableToChangeOrder && comment.Contains("because current order values already match"))
                {
                    // Do something specific for Cannot change order 'xxxxxxxxxxx' because current order values already match.
                }

                Comment


                  #23
                  Ok, this make sense...

                  Thanks for your support using examples

                  Comment


                    #24
                    Originally posted by NinjaTrader_Jim View Post
                    Hello bcomas,

                    You can consider using String.Contains from the comment string:

                    Code:
                    if(order.Name == "Trail stop" && error == ErrorCode.UnableToChangeOrder && comment.Contains("because current order values already match"))
                    {
                    // Do something specific for Cannot change order 'xxxxxxxxxxx' because current order values already match.
                    }
                    Hello Jim,

                    This not working because the messages comes from the broker and still the issue of anoying popout messages only when trading in Live trading.
                    The only way that works for me is the use of simulated stops.because it resides at PC instead the broker .
                    Hoppefully a new NT update will fix this issue from years ago.

                    Code:
                    SetTrailStop(@"", CalculationMode.Ticks, 100, [B]True[/B]);
                    Thanks for your help


                    Comment


                      #25
                      Hello bcomas,

                      You will be able to handle the error, and keep the strategy running, but the pop up will always be seen and cannot be hidden.

                      Comment


                        #26
                        I'm having a different sort of "inconsequential error," that occurs if the user drags the stop loss to the wrong side of the current price. If I have RealtimeErrorHandling set to IgnoreAllErrors it pops the stop loss back to where it was - no harm, no foul. Otherwise, if RealtimeErrorHandling is set to the default setting, it needlessly shuts down the strategy.

                        Please add my vote as well.

                        Thanks!
                        Last edited by traderpards; 12-16-2021, 12:02 PM.

                        Comment


                          #27
                          Thanks for your feedback traderpards,

                          Your vote is added.

                          Comment


                            #28
                            It's still happening, year 2023. version 8.0.27.1. Please add my vote.

                            Comment


                              #29
                              Hello FutureDragon,

                              Thanks for your note.

                              I have added your vote to this feature request.

                              Let me know if I may assist further.
                              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, 03-13-2026, 05:17 AM
                              0 responses
                              86 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              151 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              79 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              52 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              59 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X