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

"There already is a matching, filled exit order in place" error

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

    "There already is a matching, filled exit order in place" error

    Hi Ninja,

    I run a strategy I developed on NinjaTrader 7.0.1.15, with FXCM connector and more precisely CFD GER30.

    This strategy is running on "managed" mode with trace order activated.

    On the last hour of trading day, I realized several trades were ignored by NinjaTrader with the following error message:

    03/09/2013 20:17:33 Entered internal PlaceOrder() method at 03/09/2013 20:17:33: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
    03/09/2013 20:17:33 Ignored PlaceOrder() method: Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName=SellS' FromEntrySignal='' Reason='There already is a matching, filled exit order in place'

    In backtest, the same trades are filled without issues.

    At the time the trades are ignored, I have a long position and I run "ExitShort" statements.
    I would be in unmanaged mode I would try to debug it further and see what is wrong in my order handling but here in managed mode I am lost.

    Would you be able to assist?

    Many thanks and regards.

    #2
    Hi AlgoNaute, sorry to hear about the issue - do you happen to record the CFD GER30 data for replay as well, so it could be attempted to reproduce? Do you work with a single or multiseries strategy? Are you doing any advanced order handling in the managed approach via the IOrder objects and event driven methods like OnOrderUpdate() / OnExecution()?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      I was not explicitly recording the data.

      The strategy is multiserie. I used IOrder object returned by the managed entry order function just for storing information. I do not try any unmanaged manipulation in this code (which I have done on other strategy but here the requirement was not to use unmanaged for simplification and safety).

      I do not use stop loss or profit target related function. I only send market orders.

      OnExecution() is only used to read information and storing statistics. No trading manipulation here.

      This strategy run from 7am to 21pm. Around 100 trades entered. Problem only appeared on the last hour.

      What this message means exactly? What can we do about it?

      Intermediate question. From TraceOrder = true, I get the order entry trace in the output window. How can I get it on the strategy code so I can add these traces in my self generated strategy log?

      Many thanks for your help.

      Comment


        #4
        AlgoNaute, thanks for the reply. So your script remained in a long position until the ExitOnClose triggered basically and ignoring commands to reverse?

        The actual order submission is only done from BarsInProgress == 0 correct?

        The trace means exactly what it states, your Short order was ignored as the strategy had seen already a filled exit order for this position - what we now would need to look into is reproducing and understanding why this happened.

        You could unfortunately not direct the trace orders output to a custom log, it would be designed to be monitored from the NT output window directly.

        Are you currently having the script working on the CFD again? Would you mind letting me know if the issue reappeared today as well?

        If so, I would need as simple as possible script (preferably the one you ran) to be able to set it up here and reproduce and then get in touch further with my developers.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I had a position of long 10 contracts and I was trying to submit different exitlong of 1 or 3 contracts. So when I have a position, I generally to exit it totally. I can add more long contracts to it, then exit from a few contracts, then exit again, then adding more, etc.

          This order sending code should only be called on data serie 0 indeed. I will re double check that though.

          There is no way to get a call back when an order is ignored? Maybe by printing all OnOrderUpdate() call?

          Algo is being rerun, I will come back if the issue happens again.

          Thanks.

          Comment


            #6
            Thanks, so for those scaleouts, you scale in then first in the managed mode?



            OnOrderUpdate() would not be helpful, since .Ignored is not an actual orderstate from the brokerage but only NT internal as the managed approach would 'catch' it.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hi Bertrand,

              the issue repeats every day. I show here the succession of trade until we get the first error.

              07:00:15 Entered internal PlaceOrder() method at 05/09/2013 07:00:15: BarsInProgress=0 Action=Buy OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='BuyL' FromEntrySignal=''
              Position Update :3
              07:04:54 Entered internal PlaceOrder() method at 05/09/2013 07:04:54: BarsInProgress=0 Action=Sell OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='StopLoss' FromEntrySignal=''
              Position Update :0
              07:12:07 Entered internal PlaceOrder() method at 05/09/2013 07:12:07: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
              Position Update :-1
              07:16:46 Entered internal PlaceOrder() method at 05/09/2013 07:16:46: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal=''
              Position Update :0
              07:28:53 Entered internal PlaceOrder() method at 05/09/2013 07:28:53: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
              Position Update :-1
              08:00:20 Entered internal PlaceOrder() method at 05/09/2013 08:00:20: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='BuyL' FromEntrySignal=''
              Position Update :0
              08:00:58 Entered internal PlaceOrder() method at 05/09/2013 08:00:58: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell' FromEntrySignal=''
              Position Update :-1
              08:02:42 Entered internal PlaceOrder() method at 05/09/2013 08:02:42: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
              Position Update :-4
              08:03:37 Entered internal PlaceOrder() method at 05/09/2013 08:03:37: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='StopLoss' FromEntrySignal=''
              Position Update :-1
              08:06:03 Entered internal PlaceOrder() method at 05/09/2013 08:06:03: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
              Position Update :-4
              08:15:42 Entered internal PlaceOrder() method at 05/09/2013 08:15:42: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='StopLoss' FromEntrySignal=''
              Position Update :-1
              08:15:49 Entered internal PlaceOrder() method at 05/09/2013 08:15:49: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='BuyL' FromEntrySignal=''
              Position Update :0
              08:19:04 Entered internal PlaceOrder() method at 05/09/2013 08:19:04: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='StopLoss' FromEntrySignal=''
              Position Update :1
              08:49:11 Entered internal PlaceOrder() method at 05/09/2013 08:49:11: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
              Position Update :0
              09:07:43 Entered internal PlaceOrder() method at 05/09/2013 09:07:43: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
              Position Update :-3
              09:10:00 Entered internal PlaceOrder() method at 05/09/2013 09:10:00: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell' FromEntrySignal=''
              Position Update :-4
              09:32:14 Entered internal PlaceOrder() method at 05/09/2013 09:32:14: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='BuyL' FromEntrySignal=''
              Position Update :-3
              09:45:07 Entered internal PlaceOrder() method at 05/09/2013 09:45:07: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell' FromEntrySignal=''
              Position Update :-4
              09:45:10 Entered internal PlaceOrder() method at 05/09/2013 09:45:10: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
              Position Update :-7
              09:56:13 Entered internal PlaceOrder() method at 05/09/2013 09:56:13: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='BuyL' FromEntrySignal=''
              09:56:13 Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName=BuyL' FromEntrySignal='' Reason='There already is a matching, filled exit order in place'

              I would really appreciate your help as I am stuck, managed mode being a black box.

              Many thank again.

              Last edited by AlgoNaute; 09-05-2013, 04:22 PM.

              Comment


                #8
                Thanks, please see my scaleout comment in the prior post - do you scale in first for each entry you try later scale out from?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  [QUOTE]To scale out of a position refers to closing a portion of your position when you hit a profit target and then raising your stop to close your remaining portion later.[/QUOTE

                  I am not using stop loss or profit target. Only EntrLong/EnterShort or ExitLong/ExitShort.

                  Not sure what you mean by "Scale In".

                  Comment


                    #10
                    Would not be limited to target / stop exits. Let's assume you have a total position of 10 contracts, and want to scale out in 4 / 3 / 3 - then you would need scale in in the same qty's first to be able to do the scale out in the managed approach.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      If we look at the below sequence triggering the first error. You can see that I am entering like that:

                      Position flat then...
                      - 3 with Pos : -3
                      - 1 with Pos : -4
                      + 1 with Pos : -3
                      - 1 with Pos : -4
                      - 3 with Pos : -7

                      then the +1 fails. For me I am scaling. The goal actually is to emulate a trade centric strategy so any trade matches an inverse trade at one point.

                      Position Update :0
                      09:07:43 Entered internal PlaceOrder() method at 05/09/2013 09:07:43: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
                      Position Update :-3
                      09:10:00 Entered internal PlaceOrder() method at 05/09/2013 09:10:00: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell' FromEntrySignal=''
                      Position Update :-4
                      09:32:14 Entered internal PlaceOrder() method at 05/09/2013 09:32:14: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='BuyL' FromEntrySignal=''
                      Position Update :-3
                      09:45:07 Entered internal PlaceOrder() method at 05/09/2013 09:45:07: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell' FromEntrySignal=''
                      Position Update :-4
                      09:45:10 Entered internal PlaceOrder() method at 05/09/2013 09:45:10: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='SellS' FromEntrySignal=''
                      Position Update :-7
                      09:56:13 Entered internal PlaceOrder() method at 05/09/2013 09:56:13: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='BuyL' FromEntrySignal=''
                      09:56:13 Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName=BuyL' FromEntrySignal='' Reason='There already is a matching, filled exit order in place'

                      Comment


                        #12
                        Correct, but you cannot use a scale for the scale out that you did not use as scale in qty to begin with in the managed approach. So go in with 4 / 3 / 3 to get 10 and then unload by 6 / 2 / 2 > would not be expected to work. For this the unmanaged mode would be actually ideal and giving your more flexibility.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          I understand the concept. But what is wrong in my sequence? My +1 matches a previous -1. Could you be specific on what is wrong my this sequence?
                          Many thanks.

                          And why it is working in backtesting.

                          Comment


                            #14
                            But your individual scales don't have a unique name, correct? Literally each and every scale out qty needs to be scaled in via a unique signal name first. That's not what I see happening with your current approach.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              HI Bertrand,

                              thanks I understand the issue here now.

                              However, I understand also I need to go to unmanaged mode anyway to make it work properly on this sequence below:

                              Position 0
                              Trade +1 Position 1
                              Trade +1 Position 2
                              Trade +1 Position 3
                              Trade +1 Position 4
                              Trade -3 Position 1

                              For this last trade to work, I need to go unmanaged to make it work I believe, because we do not have a +3 before.

                              Regarding the unemanaged mode, can I use a succession of Buy and SellShort without BuyToCover/Sell?

                              The sequence below would work like this? Do we have to use different label or we can ignore label on unmanaged?

                              Position 0
                              Trade +1 Position 1 Buy
                              Trade +1 Position 2 Buy
                              Trade +1 Position 3 Buy
                              Trade +1 Position 4 Buy
                              Trade -3 Position 1 SellShort
                              Trade -2 Position -1 SellShort

                              Globally I want now to manage myself which trade is linked as a closure of which trade. I do not want Ninja to interfere, which is I believe the use of unmanaged mode.

                              Thanks!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by royhagerman, Today, 04:30 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post royhagerman  
                              Started by haas88, 03-21-2024, 02:22 AM
                              18 responses
                              208 views
                              0 likes
                              Last Post haas88
                              by haas88
                               
                              Started by Board game geek, Today, 02:20 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post Board game geek  
                              Started by knighty6508, Today, 01:20 AM
                              2 responses
                              15 views
                              0 likes
                              Last Post knighty6508  
                              Started by franatas, Today, 01:53 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post franatas  
                              Working...
                              X