Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    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
        JimNinjaTrader Customer Service

        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);
            }
            JimNinjaTrader Customer Service

            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.
                }
                JimNinjaTrader Customer Service

                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.

                      JimNinjaTrader Customer Service

                      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.
                          JimNinjaTrader Customer Service

                          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.
                              Brandon H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rt61968, 02-17-2018, 05:24 PM
                              3 responses
                              2,733 views
                              0 likes
                              Last Post MasterEtrad3  
                              Started by nuobo, Today, 07:43 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post nuobo
                              by nuobo
                               
                              Started by ETFVoyageur, Today, 02:04 PM
                              3 responses
                              21 views
                              0 likes
                              Last Post ETFVoyageur  
                              Started by cre8able, Today, 06:18 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post cre8able  
                              Started by ETFVoyageur, Today, 06:05 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post ETFVoyageur  
                              Working...
                              X