Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit order overfilled

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

    Limit order overfilled

    Hi,

    I'm on the overfilling issue. I want to enter with a limit order. Simple limit oders are allways overfilled. I read about the unmanaged option but I don't want to consider it because it could extremely complicate my strategy creating many issues.

    Instead of this I use this entrylimit:

    MyOrder = EnterLongLimit(0,true,NumShares,GetCurrentAsk(),"" );

    In order handling I cancel the order when the order is Filled. If not, the enterlonglimit remains active.

    I'm doing something wrong because after the order is filled it is automatically closed.

    From traceorders I get this:

    **NT** Enabling NinjaScript strategy 'HFTSimple/409a1d1d96a442ed94df4f10f68fe17e' : On starting a real-time strategy - StrategySync=SubmitImmediately SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=TakeNoAction ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
    8/25/2011 10:35:36 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:36 AM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=43,145 LimitPrice=5.70 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:36 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:36 AM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=42,520 LimitPrice=5.70 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:36 AM Amended matching order: Action=SellShort OrderType=Limit Quantity=42520 LimitPrice=5.70 StopPrice=0 SignalName=Sell short' FromEntrySignal=''
    8/25/2011 10:35:36 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:36 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=21,652 LimitPrice=5.71 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:36 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:36 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=21,298 LimitPrice=5.71 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:36 AM Amended matching order: Action=Buy OrderType=Limit Quantity=21298 LimitPrice=5.71 StopPrice=0 SignalName=Buy' FromEntrySignal=''
    8/25/2011 10:35:36 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:36 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=21,732 LimitPrice=5.71 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:36 AM Amended matching order: Action=Buy OrderType=Limit Quantity=21732 LimitPrice=5.71 StopPrice=0 SignalName=Buy' FromEntrySignal=''
    8/25/2011 10:35:58 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:58 AM: BarsInProgress=1 Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=5.57 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:58 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:58 AM: BarsInProgress=1 Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:58 AM Amended pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=Working Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=42,520 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'
    8/25/2011 10:35:59 AM Amended pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=Working Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=32,874 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'
    8/25/2011 10:35:59 AM Amended pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=PendingChange Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=27,335 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'
    8/25/2011 10:35:59 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:59 AM: BarsInProgress=1 Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=5.57 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:59 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=5.57 StopPrice=0 SignalName=Buy to cover' FromEntrySignal='' Reason='There already is a matching order with same prices and quantity'
    8/25/2011 10:35:59 AM Entered internal PlaceOrder() method at 8/25/2011 10:35:59 AM: BarsInProgress=1 Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:35:59 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName=Buy to cover' FromEntrySignal='' Reason='There already is a matching order with same prices and quantity'
    8/25/2011 10:35:59 AM Amended pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=PendingChange Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=25,335 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'
    8/25/2011 10:36:03 AM Amended pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=Working Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=24,424 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'
    8/25/2011 10:36:06 AM Amended pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=Working Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=21,175 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'
    8/25/2011 10:36:06 AM Amended pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=PendingChange Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=19,365 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'
    8/25/2011 10:36:06 AM Entered internal PlaceOrder() method at 8/25/2011 10:36:06 AM: BarsInProgress=1 Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=5.57 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:36:06 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=5.57 StopPrice=0 SignalName=Buy to cover' FromEntrySignal='' Reason='There already is a matching order with same prices and quantity'
    8/25/2011 10:36:06 AM Entered internal PlaceOrder() method at 8/25/2011 10:36:06 AM: BarsInProgress=1 Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    8/25/2011 10:36:06 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName=Buy to cover' FromEntrySignal='' Reason='There already is a matching order with same prices and quantity'
    8/25/2011 10:36:07 AM Amended pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=PendingChange Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=8,232 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'
    8/25/2011 10:36:07 AM Cancelled pending exit order, since associated position is closed: Order='46799323/DU115266' Name='Buy to cover' State=PendingChange Instrument='ING' Action=BuyToCover Limit price=5.57 Stop price=0 Quantity=3,339 Strategy='HFTSimple' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='08a273ea6c344b5b814bb6c17c2a663e' Gtd='12/1/2099 12:00:00 AM'

    #2
    guillembm, you would need to debug the events sequents received for your strategy order submission, if the Cancel / PendingCancel state is seen before you receive any fill (even a partial) it would flag the order as overfilled then.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks. But I thought that enabling liveuntilcancelled=true would avoid this.

      This is why I use this order structure:

      MyOrder = EnterLongLimit(0,true,NumShares,GetCurrentAsk(),"" );

      Is this wrong?

      Comment


        #4
        guillembm, this would only avoid the order would auto expire at the next OnBarUpdate() seen, it would not prevent any overfill from being seen if you cancelled / attempted to cancel the order before the fill came in then.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Then, without considering the unmanaged approach what is the solution.

          Do you have any sample code?

          Comment


            #6
            I would unfortunately not have a sample here, you would need to debug your strategy to work with as less as possible competing orders close to the inside market so the chance of generating overfills is reduced.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              You mean that if the entry order is being filled I open a limit exit order and they are active at the same time this would be the problem?

              Comment


                #8
                While the entry order is being filled with partial fills I have another limit exit order. Do you understand?

                Comment


                  #9
                  Consider this scenario for example:

                  1. You place a limit order
                  2. You attempt to cancel it and modify.
                  3. While 2 happens fills already are reporting back, which would mean as far as NT's tracking goes, the order is overfilled, as our last known state was cancelled and now we're getting a fill reported for it.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Thanks. I understood the problem.

                    I think I found the solution. I had to limit orders competing. After launching the enterlimit I immediately launched an exitlimit. This one cancelled the first while fills were being reported.

                    I just had to wait the first to be filled to launch the exitlimit

                    Comment


                      #11
                      Glad to hear, thanks for reporting back here.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        By the way, Bertrand.

                        I see that you are German. I can't get data from German stocks from TWS. Can you help me about this? What are the right settings in Instrument Manager to retrieve data? Even placing manual orders these stand in a Pending Submit status. I'm sure the subscription is right because I can place direct orders from TWS

                        I can open a new thread directly to you?

                        Comment


                          #13
                          Which stocks would you be trying to access then? If you like, please send me an email to suppoprt at ninjatrader dot com to my Attn so we can work this out.

                          Danke
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Greetings guillembm,
                            I am having the same problem you were; would it be possible for you to post just the lines of code you're using to get around this issue(I'm new to NT & also a programming novice).
                            Appreciate any help,
                            hbmiles2000

                            Comment


                              #15
                              hbMilles,

                              THe code I added to my strategy to avoid overfilling is disseminated along the strategy. Better than doing this I will explain my solution as a pseudo-code

                              THe scenario that produced the error was:
                              - I launch an EnterLongLimit() to open a position.
                              - On the next bar I launch an ExitLongLimit() order to set a sort of stop profit target.
                              - If, when launching the ExitLongLimit() order, the EnterLongLimit() wasn't completely filled and a new partial fill came after this point this caused the error.

                              Following the instructions of the customer service the rule to follow to avoid this problem is to never have two active limit orders competing at the same time.

                              So, I had to change the code to avoid the EnterLongLimit() and the ExitLongLimit() orders being active at the same time.

                              The new steps to do the same are:
                              1- I launch an EnterLongLimit() to open a position.
                              2- I set two conditions and one of them must be accomplished before launching the ExitLongLimit() order.
                              -- First condition: the order must be filled. For this I use IOrder methods (http://www.ninjatrader-support.com/H...rumentFullName)
                              -- Second condition: I'm never sure that an order will be completely filled. To solve this I wait a prudential number of bars and then I cancel the EnterLongLimit() order. This code could be useful: http://www.ninjatrader-support.com/H...ml?CancelOrder
                              3- After one of these conditions are accomplished I can launch the ExitLongLimit() order without creating an overfill issue.

                              Hope it helps

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by i2ogu3, Yesterday, 11:31 PM
                              2 responses
                              17 views
                              0 likes
                              Last Post i2ogu3
                              by i2ogu3
                               
                              Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
                              21 responses
                              68 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by llanqui, Today, 11:13 AM
                              5 responses
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by llanqui, 04-28-2024, 10:32 AM
                              10 responses
                              38 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by samish18, 04-17-2024, 08:57 AM
                              27 responses
                              118 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X