Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Repetitious cancellation orders grinding system to a halt

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

    Repetitious cancellation orders grinding system to a halt

    I'm running a strategy in simulation mode. Each bar that I have a position on I update the stop and target levels depending on market action. However, I have noted that over time (only a few hours) CPU activity becomes maxed out.

    Examining the log output of NT I see that the system is sending several requests per second to cancel the same order, even after the position is long since dead. This doesn't happen on every order cancellation (and the vast majority take place without a hitch) but it's enough to grind the system to a halt over the period of a few hours.

    Here is an example log output;

    Code:
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Cancelled Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Cancelled Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Cancelled Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Cancelled Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Cancelled Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=PendingCancel Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=PendingCancel Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Working Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Accepted Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=PendingChange Instrument='ES 03-09' Action=BuyToCover Limit price=686.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Working Instrument='ES 03-09' Action=BuyToCover Limit price=686.5 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=Accepted Instrument='ES 03-09' Action=BuyToCover Limit price=686.5 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    09/03/2009 16:27    Order    Order='ce2f6c8c15aa459b8484c1a33f270bfb/Sim101' Name='Profit target' New State=PendingSubmit Instrument='ES 03-09' Action=BuyToCover Limit price=686.5 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    You can see that the first few log messages (at the bottom in chronological order) make sense - the order is being processed and the next bar its amended. When the position is closed out (my logic makes an exit decision or a stop/target is hit) a request is sent by NT automatically to cancel the target order in the market. Except this last request keeps on getting sent, several times a second with no termination. In fact, it will keep on sending this even if I stop or even remove the strategy. It will only stop sending these requests when I disconnect the data feed.

    Any ideas?

    thanks

    #2
    Please provide the code snippet where you are cancelling orders. Thank you.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I don't manually cancel orders. I leave NT to do this. I am using NT in its default setting of letting orders only last till the end of the bar. All my code runs inside of OnBarUpdate().

      This is the code I use to enter a long position, setting a corresponding stop and target immediately;

      Code:
      EnterLongLimit( orderQuantity, entryPrice, entryTag );
      SetStopLoss( entryTag, CalculationMode.Price, stopPrice, false );
      SetProfitTarget( entryTag, CalculationMode.Price, targetPrice );
      The position is therefore exited if a stop or target is hit OR if one of my exit criteria is met. If the exit criteria is met, this is the code I use to exit;

      Code:
      ExitLong( BarsInProgress, orderQuantity, exitTag, entryTag );
      In addition, I also have code which checks that I don't double cover a position due to my exit logic coinciding with the trigger of a stop or target. In this case, since I can't guarantee a matching tag, I use;

      Code:
      ExitLong( orderQuantity );
      Hope this helps.
      Last edited by trader_rick; 03-09-2009, 11:20 AM.

      Comment


        #4
        Hmm. Do you have a reproducible scenario? We would like to test it on our end. Thank you.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Not sure what you mean by scenarios.

          I'm running it on ES with bars set to 150 Ticks. I'm using eSignal as the external feed. I've also written my own data feed server where I can control the data and speed of the push through but I get the same result with both sources (in the latter case, I send ticks through every 0.5 seconds and use 20 Tick bars.)

          In the meantime I'll clone my strategy and then try progressively simplifying the strategy logic to try and isolate the cause more i.e. is it something in my strategy or within NT itself.

          thanks for the help Josh

          Comment


            #6
            trader_rick,

            I cannot comment on what it is at this point in time. If you have a replay file with a strategy that can reproduce it that would be perfect.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              OK Josh.

              For obvious paranoid trader reasons I won't submit my strategy as is but I will try and edit out my trading logic and then will submit it to you along with replay data after I've confirmed I'm still getting the same errors.

              Comment


                #8
                Thank you.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Josh,

                  OK, this is going to sound strange but this is what I have so far.
                  I incrementally started clipping away more and more blocks of code, testing in between whether I still had the same problem, which I did.

                  When I got to about 600 lines of code, the problem disappeared. However, the most recent code that I had removed had nothing to do with order entry. I therefore went back to the last buggy copy (I kept versions of each edit along the way) and this time removed a different block of code. Again, the bug disappeared.

                  My conclusion therefore is that there is some weird kind of compilation error, possibly due to a corrupted source file. I tried cutting a block of code out of my last buggy copy and repasting it in, in a different location (I just cut out some function bodies) but via Notepad in order to avoid copying back in any corrupted portions. The bug remained. I also tried saving the source file with a different encoding but the bug still remained. (I use a 3rd party editor.) Anyway, I don't think that there is any fault that can be attributed to the code logic itself, so I don't think sending you my strategy is going to be helpful.

                  What are your thoughts?

                  Comment


                    #10
                    trader_rick,

                    Unfortunately I cannot assess your scenario. All I can suggest is maybe try a completely clean reinstall, with the removal of My Documents\NinjaTrader 6.5 before reinstalling. Please make any backup of information you want first. As you reinstall NT, do not import back any of your old settings. Just bring back the one strategy and see what happens then.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Already tried that. Problem persists.

                      What I'll try next is the reverse to my strategy disassembly process. I will incrementally add to the strategy code starting from a blank strategy and test in between to make sure everything is OK. Hopefully that will do the trick. If it's not, I should at least be in a position to pinpoint exactly where the problem is.

                      thanks for your support

                      Comment


                        #12
                        Thank you for your efforts. Please let us know if you find something interesting.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          I am having this issue also. It occured today when I reversed two existing short orders that were entered with myEntryOrder = EnterShortLimit()... with EnterLong(). The profit target order of the short order got stuck in this cancellation loop.

                          Comment


                            #14
                            Suggest you debug your strategy by commenting out everything except essentials and then slowly layering on complexity till you find where it breaks.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              It breaks when my system puts in a reversal market order on an existing limit order. My strategy executes on bar close so I don't see any reason why a cancel order would be repeated several times a second due to strategy logic. Perhaps this is a NinjaTrader bug that should be fixed.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              44 views
                              0 likes
                              Last Post jeronymite  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              7 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              10 responses
                              180 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X