Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancelled Exit Market Orders

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

    Cancelled Exit Market Orders

    All,

    I’ve been doing a bit of research on a bug I’m seeing. My ExitLong() market order is being cancelled, telling me there is no corresponding position to exit:

    20/08/2008 00:00:00 Entered internal PlaceOrder() method at 20/08/2008 00:00:00: Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    13/08/2008 00:00:00 Cancelled pending exit order, since associated position is closed: Order='NT-00005/Back101' Name='Sell' State=PendingSubmit Instrument='$USDCAD' Action=Sell Limit price=0 Stop price=0 Quantity=0 Strategy='TripleMACrossv4' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='678b79bd92b54d23bb35157d236eb2a6' Gtd='01/12/2099 00:00:00'

    I am working on a simple multiple MA cross over with an ADX set-up requirement.

    I am relatively new to Ninja Trader, so I freely admit that this could be how I’m handling the IExecution or IOrder objects in the strategy. However, I got a little concerned when I saw the thread here: http://www.ninjatrader-support2.com/vb/showthread.php?t=12619

    This talks of an bug that is causing the cancelling of pending orders here as well: http://www.ninjatrader-support2.com/vb/showthread.php?t=14674

    It mentions it is fixed in [FONT='Verdana','sans-serif']release 6.5.1000.9 (which I am running), however, I am seeing much the same symptoms.[/font]

    [FONT='Verdana','sans-serif']Could someone confirm this isn’t the same bug / related bug?[/font]

    [FONT='Verdana','sans-serif']I have attached a screen shot of the order log in the strategy analyser as well.[/font]

    [FONT='Verdana','sans-serif']Kind regards,[/font]

    [FONT='Verdana','sans-serif']Dan[/font]
    Attached Files

    #2
    First thread: issue resolved for awhile now.
    Second thread: resolved awhile ago too.

    Please instead post evidence of what you are experiencing. Simplify your setup to the bare essentials and use TraceOrders = true to understand what your orders are doing.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      Thank for the amazingly prompt reply. It is appreciated.

      Good news on the issues being resolved, let’s hope it is my misuse of the IOrder, IExecution or OnOrderUpdate elements of Ninja Script that is causing the error.

      With regards to “evidence”, what other information would you prefer?

      I have used the Traceorders function in the initialise part of the script. The output in the middle of my previous post is the outcome of using the traceorder function. The odd bit of the output is where the strategy analyser calls back to the 13/04/2008, even though the market exit order is being executed on the 20/08/08. Would you prefer for me to post this information in another way?

      To be more specific regarding the data this strategy is being run against, it is USDCAD between the dates of 01/07/2008 – 28/11/2008.

      I have also included a screen shot here of the order entry, then of the exit on close.

      Kind regards,

      Dan
      Attached Files

      Comment


        #4
        If you could post the complete TraceOrders output it would make more sense for us to evaluation purposes. Thank you.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh,

          Thank you again for the amazingly prompt support.

          I’ve attached in a text file a copy from the output window. Please note that I have used some Print statements into the script to assist with debugging.

          Kind regards,

          Dan
          Attached Files

          Comment


            #6
            drolles,

            Your code is performing as expected.

            You have:
            Code:
            Print("exiting long @ 113");
            ExitLong();
            Then your output is this:
            Code:
            exiting long @ 113
            20/08/2008 00:00:00 Entered internal PlaceOrder() method at 20/08/2008 00:00:00: Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
            13/08/2008 00:00:00 Cancelled pending exit order, since associated position is closed: Order='NT-00005/Back101' Name='Sell' State=PendingSubmit Instrument='$USDCAD' Action=Sell Limit price=0 Stop price=0 Quantity=0 Strategy='TripleMACrossv4' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='678b79bd92b54d23bb35157d236eb2a6' Gtd='01/12/2099 00:00:00'
            13/04/2009 20:03:29 Cancelled pending exit order, since associated position is closed: Order='NT-00005/Back101' Name='Sell' State=Initialized Instrument='$USDCAD' Action=Sell Limit price=0 Stop price=0 Quantity=0 Strategy='TripleMACrossv4' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d8eaff23f9aa469996cd23fe3578907b' Gtd='01/12/2099 00:00:00'
            This means you called ExitLong() and closed your position. It then goes and cancels your ExitLongStop() order because there is no more open position for it to link to.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh,

              Thank you again for your precise and prompt help.

              Though, I have to admit I’m a little confused with your reply.

              The stop_order is already being cancelled by the code previous to that point – see lines 107 – 110. There should be no stop order for it to cancel.

              Also if you note the order tokens, they don’t align with what they should. On the original post I included a screen shot of the orders tab in the strategy analyser. If I have understood your reply correctly, the order tab output does not bear out what you are saying.

              Kind regards,

              Dan

              Comment


                #8
                Dan,

                Sure you placed in CancelOrder() commands, but you did not wait for the cancellations to actually come back as cancel. As such it is very possible to have your ExitLong() go in and fill before those CancelOrder()'s came back. This is one potential cause for why you receive the no open position message.

                Not sure what you mean by your token comment. The 678B.. token matches up.

                I suggest you add Print()s into OnOrderUpdate() method so you can watch each order change through order states.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Josh,

                  Thank you again for your help.

                  Thank you for clarifying the mystery around the orders being cancelled – I will have to do more work in understanding the ordering of the events from the OnOrderUpdate() function.

                  Just to be sure I understand what you are say: Are you saying that I need to confirm that there are no outstanding orders before I can exit the position?

                  Unfortunately, though I remain confused. I thought, from the documentation I had read, that the market position should still been able to be exited while the exitlongstop() order was still active. That is, the market order – which gets triggered due to the MA cross over condition being met (line 103) – should be closing the position. Then that doesn’t explain why the a position is left open.

                  The order token that should be filled in the exit market condition which is the one you reference. The screen shot from the Strategy Analyser shows that it isn’t being filled. In fact, the strategy analyser is closing out the order at the end of the back test, which is order token 93...

                  To make sure I’m clear in what I am saying, let me summarise it here: thanks for clarifying the ordering of the events. I need to do more homework on this. However, that explanation doesn’t appear to provide a reasoning for the non-fill of the market order (token 678b...) which should be closing the position.

                  Please don’t hesitate to let me know if I have miss understood you.

                  Kind regards,

                  Dan

                  Comment


                    #10
                    You may be dealing with a bug where you can't submit additional exit orders after you cancel exit orders that were originally tied to them. Instead of cancelling I suggest you just submit a limit order that is guaranteed to fill to close your position. That will preserve your signal tracking and prevent this scenario.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Josh,

                      Thank you again for your persistence in solving this issue.

                      Investigating the bug you refer to, I pulled out the cancellation requests for the exitlongstop(), you are correct. The bug is as expected. Once you stop trying to cancel the exitlongstop() and just rely on the ExitLong() to take the position out, then the strategy performs as expected. The market exit order takes out the position correctly.

                      Given we now touch on it, is the bug listing for NT anywhere, so that others can be aware of this bug?

                      Thanks again for your swift help and persistence.

                      Kind regards,

                      Dan

                      Comment


                        #12
                        Dan,

                        It is on our list and is already resolved for our NT7 development.
                        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
                        558 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        324 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        101 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        545 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        547 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X