Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

order rejected - stategy closed

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

    order rejected - stategy closed

    Hello,

    I´m backtesting different ways of stops and when the stop order is rejected eg because to close to price or price moved away other direction - no matter this is part of the idea and testing what might happen in fast moving markets - then there appears "order rejected... strategy closed". How can one avoid that the strategy is closed in such a case? No problem that the order is rejected - this is what I´m going to improve with my "Twin-Stops"

    For better understanding I bring up an ExitLongStop 1 pip below Bid instead of ExitLong. This way I have the chance to stay in the market when price continues my direction. But if it goes - fast - the other way then the stop might be rejected. For this I have a "TwinStop" with more distance and I coded it so that if one is triggered then the other is closed also.

    The only problem that occurs with this idea is now that the strategy is closed with rejecting order.

    Thanks
    Tony

    #2
    Tony, for experienced programmers there's the option to turn off the Realtime error handling that would step in when you see a rejected order from the script - http://www.ninjatrader.com/support/h...htsub=realtime

    With this turned off, the script would continue to run and you can monitor for the rejection and resubmit or send another order as desired.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,

      thank you for your reply. I´m not an experienced programmer, but now finished with all my coding and I think I can add "TakeNoAction" to my scripts.

      And how can one cancel in the script then an order that has been rejected please the best way?

      would you do this with " != null (as I think its not null only because its rejected) && orderstate.rejected) then CancelOrder?

      Thank you for your support again after all!

      Best
      Tony

      Originally posted by NinjaTrader_Bertrand View Post
      Tony, for experienced programmers there's the option to turn off the Realtime error handling that would step in when you see a rejected order from the script - http://www.ninjatrader.com/support/h...htsub=realtime

      With this turned off, the script would continue to run and you can monitor for the rejection and resubmit or send another order as desired.
      Last edited by tonynt; 03-07-2013, 03:24 AM. Reason: typing error

      Comment


        #4
        Tony, you can check into the example offered in the helpguide to manage the rejection in OnOrderUpdate(), you're correct the rejected order would not be nulled per se, there should be no need for a CanceOrder then, as this order would not be 'working' or 'accepted' anymore.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Please, last issue to help out.

          I can do with Iorder almost now all I need for my stop managment but I dont understand how I can do when 2 orders need to be in the condtions because there is only one "order" in the syntax EG

          if (stopOrder1a != null && stopOrder1a == order
          && stopOrder1b != null && stopOrder1b == order )
          {
          // stopOrder1a
          if (order.OrderState == OrderState.Rejected)
          //stopOrder1b
          && (order.OrderState==OrderState.Accepted)
          {
          //Then do....
          }


          THANK YOU!
          Tony

          Originally posted by NinjaTrader_Bertrand View Post
          Tony, you can check into the example offered in the helpguide to manage the rejection in OnOrderUpdate(), you're correct the rejected order would not be nulled per se, there should be no need for a CanceOrder then, as this order would not be 'working' or 'accepted' anymore.

          Comment


            #6
            Correct Tony, this would be called individually per order you would 'listen' to. You could tie those calls together then via custom logic like for example a bool flag. I'm not sure why you seek to work with two potentially competing orders close to the market here, as this would be pretty much 'asking' for overfills issues.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thank you.

              I tell what I´m doing as it seems you are interested why and what with your answer. And you tell me please more accurately how to do

              When certain pips in profits I seperate my initial stop for eg 6 longs to a stop1b with 4 longs which I set to breakeven and another stop 1a to set 1 pip below the current pip (instead of exitlong at this price, for having the chance to stay in the trade when it continues)

              But for all circumstances that can occur I have to code for exits and cancelling. One of the situations - or better the important here - is that because of fast moving markets the stop1a at the bid is rejected. To handle my positions correctly I have to do "if stop1a == rejected and stop 1b accepted then do"

              PS: I know the sample scaleIN/OUT but for certain reasons (eg to many lines on brokers platform directly) I want to have one position and to scale out from this.

              Please tell me how I can do the both orders in the syntax (as this is not in the samples of helpguide with more than one order) as you got the idea now.

              THANK YOU FOR YOUR SUPPORT!

              Best
              Tony


              Originally posted by NinjaTrader_Bertrand View Post
              Correct Tony, this would be called individually per order you would 'listen' to. You could tie those calls together then via custom logic like for example a bool flag. I'm not sure why you seek to work with two potentially competing orders close to the market here, as this would be pretty much 'asking' for overfills issues.

              Comment


                #8
                Tony, let's take that back a step, are you working in Unmanaged mode now with your strategies?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  No managed mode.


                  Originally posted by NinjaTrader_Bertrand View Post
                  Tony, let's take that back a step, are you working in Unmanaged mode now with your strategies?

                  Comment


                    #10
                    Tony, I would then set for example a bool flag with your partial stop order for example returned accepted. Then you can check that off in case you see a rejection of the other order, so you would have your condition outlined triggered. I'm not sure that's the most straightforward way, since I would just resubmit each order as needed if rejected and go via market if the # of rejection tries or actual time was exceeded.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Bertrand, thank you for your support but I dont understand what you mean.

                      How can I do in OnExecution please to work with exitOrder and stopOrder both as a " && condition". This is easy in onbarupdate but I dont know how to do in onExecution because there is no sample to do so. All samples are with one of them!

                      if (exitOrder1a != null && exitOrder1a == execution.Order&& execution.Order.OrderState == OrderState.Filled)

                      {
                      if(stopOrder1 != null && stopOrder1 == execution.Order&& execution.Order.OrderState == OrderState.Accepted)
                      { // then....

                      If there would be one sample how to use 2 orders (exit, stop) I wouldn´t need to ask you.

                      Thank you.
                      Tony


                      Originally posted by NinjaTrader_Bertrand View Post
                      Tony, I would then set for example a bool flag with your partial stop order for example returned accepted. Then you can check that off in case you see a rejection of the other order, so you would have your condition outlined triggered. I'm not sure that's the most straightforward way, since I would just resubmit each order as needed if rejected and go via market if the # of rejection tries or actual time was exceeded.

                      Comment


                        #12
                        Tony, OnExecution() is called for each incoming fill individually and OnOrderUpdate() for any order state change, also individually per IOrder object used. You would need to build logic that takes that into consideration, as those state updates or executions would not be hitting at the same time.
                        BertrandNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bortz, 11-06-2023, 08:04 AM
                        47 responses
                        1,607 views
                        0 likes
                        Last Post aligator  
                        Started by jaybedreamin, Today, 05:56 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post jaybedreamin  
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        19 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by Jon17, Today, 04:33 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post Jon17
                        by Jon17
                         
                        Started by Javierw.ok, Today, 04:12 PM
                        0 responses
                        15 views
                        0 likes
                        Last Post Javierw.ok  
                        Working...
                        X