Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

crash on order handling

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

    crash on order handling

    I am using AtmStrategyCreate to place sell/buy stop orders close to (2 ticks) the market last trade price

    this works fine until the market (NQ) moves 5 ticks while I am in the middle of placing an order

    of course checking where the market is prior to placing the order is not working as the market move occurs within a few milliseconds

    so I get the attached error and NT8b4 freezes...i.e. must use Task Manager to close NT and then the usual delays occur while restarting and reconnecting....not good during live trading

    I do not mind the error as I can work around it.

    I do mind the crash/freeze after the error as I can not recover/continue trading

    1. From my reading of IOrder, OnOrderUpdate, OnExecution and Unmanaged = true, etc....all these methods seem to only apply to EnterLong and EnterShort orders and not to AtmStategyCreate orders...correct?

    2. How can I handle the error to avoid the crash?

    Thanks
    Attached Files

    #2
    Somone will follow up Monday.
    RayNinjaTrader Customer Service

    Comment


      #3
      1. You are correct in that they do not apply to AtmStrategyCreate().

      2. Please provide the trace/log files. Did it really crash with an error or was it just hanging for a little bit?
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        NT crashed.....could not select any charts or functions in NT for more than 10 mins

        could not close it without using Task Manager

        consistent crash everytime at exactly same time of replay data....9:32:31....which is when market jumped 4 or 5 ticks while the trade was being placed

        will recreate later today and set you trace/log

        Comment


          #5
          beta 5 in not crashing under the same circumstances ..i.e. trying to place a sell stop order above the market

          however, it does leave a filled position uncovered

          my solution at this point is to Close from DOM which clears all positions and then Enable the strategy again

          can you please suggest a better way of dealing with/avoiding uncovered orders

          thanks

          Comment


            #6
            Check status in your code for actual submission of the ATM strategy.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              the order that is rejected is Stop1 ...coming from an AtmTemplate with a 6 tick initial stop

              the Atm was triggered by a BuyStop

              mkt goes up, hits the stop, fills the order....mkt drops before 6 tick sell stop can be placed

              see attached

              long fill at 1748.50....trying to place 6 tick stop at 1747.00....market already too low

              obvious answer is to use a wider stop....and I could have atm start wide and close....however, I was hoping for a more elegant solution...i.e. no uncovered long position
              Attached Files

              Comment


                #8
                ATI user,

                Would have to be handled by your code. Check ATM stop/target status. When its rejected like that you want to go ahead and kill that position.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Josh

                  Thanks once again for leading me to the obvious....should have thought of that myself.

                  One problem remains...

                  using GetAtmStrategyMarketPosition ( "Stop1", atmStrategyIdLONG ) for the open long position does not return 'Rejected' because in the Log the order that is rejected is not the same ID as related to atmStrategyIdLONG ...and of course the OrderId related to atmStrategyIdLONG is long since set to null as the original buystop has been filled...

                  in other words, the rejected order ID is not generated from my code but rather seems to be internal from the ATM template.

                  how do I get my hands on that ID?
                  Last edited by ATI user; 12-02-2009, 04:19 PM.

                  Comment


                    #10
                    Please try using GetAtmStrategyStopTargetOrderStatus().

                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      yet another Copy/Paste error in my post...I am already using that

                      here is the whole code:


                      // check for uncovered long positions
                      if ( atmStrategyIdLONG[i] != null && atmStrategyIdLONG[i].Length > 0
                      && GetAtmStrategyMarketPosition(atmStrategyIdLONG[i]) != Cbi.MarketPosition.Flat )
                      {
                      string[,] orders = GetAtmStrategyStopTargetOrderStatus( "Stop1", atmStrategyIdLONG[i] );
                      if (orders.Length > 0)
                      {
                      for ( int k = 0; k < orders.GetLength(0); k++ )
                      {
                      Print("399 Current state "+(i+1)+" " + orders[k, 2].ToString() );
                      Print("399 atmStrategyIdLONG "+(i+1)+" "+ atmStrategyIdLONG[i].ToString() );
                      Print("399 orderIdLONG"+(i+1)+" "+ orderIdLONG[i].ToString() ); // this is always null at this point
                      if ( orders[k, 2] == "Rejected" )
                      {
                      Print("402 *********** stop loss order rejected *********** " ); // has never printed because wrong ID
                      }

                      Comment


                        #12
                        Not sure I follow. When you get entered you must have provided an ATM strategy ID. That ID is the one you want to use.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          that is the ID I am using

                          however the ID of the stop that is rejected does not have that ID....which is why I have not been able to print the rejected error per the code above..

                          I have been trying to send better data to you however beta 5 keeps freezing

                          you should be able to reproduce at your end
                          1. download NQ for 27 nov
                          2. create an atm template with a 6 tick stop
                          3. goto 9:32:20 EST i.e. just after open
                          4. place a buy stop above mkt at 1748.50
                          5. play MR at 1x and NT will lock up at 9:32:30 ....9 times out of ten it will just freeze...sometimes it will throw the error and I am able to pause and review data....the last 5 times I have tried this, it froze......so consistent it should work for you also

                          Comment


                            #14
                            Originally posted by ATI user View Post
                            that is the ID I am using

                            however the ID of the stop that is rejected does not have that ID....which is why I have not been able to print the rejected error per the code above..

                            I have been trying to send better data to you however beta 5 keeps freezing

                            you should be able to reproduce at your end
                            1. download NQ for 27 nov
                            2. create an atm template with a 6 tick stop
                            3. goto 9:32:20 EST i.e. just after open
                            4. place a buy stop above mkt at 1748.50
                            5. play MR at 1x and NT will lock up at 9:32:30 ....9 times out of ten it will just freeze...sometimes it will throw the error and I am able to pause and review data....the last 5 times I have tried this, it froze......so consistent it should work for you also
                            I just tried my above suggestion and, although there is a slight pause (< 2 sec) at 9:32:30, NT7 beta 5 does not freeze or throw an error message.

                            So... buy stop is placed and filled fill at 1748.50 ...mkt drops instantly to 7 ticks lower, the stop is placed 6 ticks lower and filled at the entry fill price at 1748.25 (see pic)

                            for some reason my code does not handle the quick move without beta 5 freezing

                            what can be the difference in that all my code does is place the exact same buy stop at the same price???
                            Attached Files

                            Comment


                              #15
                              If you can strip your code to the bare essentials (none of those arrays things) and strip all unnecessary logic out. I will try your code on my end. Please also provide the exact replay file you are using and information on how you have your ATM strategy setup in the DOM. Thank you.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              607 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              353 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
                              560 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              561 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X