Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order handling question - unmanaged?

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

    Order handling question - unmanaged?

    Hi there,

    I have this persistent problem (first seen in NT6.5) which is again materializing in NT7.

    - I put in a exit limit order.
    - After waiting X seconds (and the limit order isn't filled), I cancel the limit order.
    - In the OnOrderUpdate() for the canceled order, after seeing the order is fully canceled, I enter a new exit at market order.

    Unfortunately, sometimes Ninja chokes on this and ends up with:

    5/26/2011 4:31:32 AM Entered internal PlaceOrder() method at 5/26/2011 4:31:32 AM: BarsInProgress=7 Action=BuyToCover OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName='MexitKC 07-11|72|LN 161' FromEntrySignal='KC 07-11|72|LN 161'
    5/26/2011 4:31:32 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=3 LimitPrice=0 StopPrice=0 SignalName=MexitKC 07-11|72|LN 161' FromEntrySignal='KC 07-11|72|LN 161' Reason='There already is a matching, filled exit order in place'

    ... I don't know how it determined there is a "matching, filled exit order in place". There are no other pending/filled orders for this instrument within the previous hours. I wonder if its referring to the (unfilled) canceled limit order.

    So, two questions:

    1) Is there something I can or should do differently to get Ninja to fill this order correctly?

    2) Can someone give me a quick primer on the "unmanaged" enter/exit orders? Can I mix/match the usage of those orders with the standard versions, or do I have to commit to one or the other?

    EDIT: Let me clarify, there is clearly some kind of a race condition going on. This problem doesn't happen EVERY time... it only happens every.. 20? 30? similar orders. So, there must be some kind of state in the Ninja order-handling background that isn't being set/cleared correctly.
    Last edited by heech; 05-26-2011, 09:57 AM.

    #2
    Hi Heech, on which NT7 release version are you testing this currently? Is this the most current R5?

    So before submitting the market exit you're waiting for a confirmed cancellation confirmation, correct?

    For the order submission mode generally in NT7, it would be either managed or unmanaged - those could not be mixed unfortunately as they use different tracking and also the unmanaged would remove the internal order handling rules for ultimate flexibility.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yes, this is the most recent release 5. As far as confirming "fully" canceled, here's the (relevant) logic from OnOrderUpdate (order is the passed in IOrder):

      if (order.OrderState == OrderState.Cancelled)
      {
      ExitShort(bar, numshares, "Mexit" + state.config.OrderName, state.config.OrderName);
      ..
      }

      The *bar* is actually calculated value, where I figure out the bar that should belong to this instrument... since this is a multi-instrument strategy. (And I must have picked the right bar, since the instrument being traded is correct.)

      I am definitely willing to use the unmanaged. Can you tell me where to look in the documentation?

      Comment


        #4
        For what its worth, the trace file shows this:

        Code:
        2011-05-26 04:31:32:256 (jceVision) Cbi.Order.CancelNow: Order='5735bec7e0ed4aeaae23b115f025f350/Sim101' Name='LexitKC 07-11|72|LN 161' State=Working Instrument='KC 07-11' Action=BuyToCover Limit price=266.234 Stop price=0 Quantity=3 Strategy='ProtectDownMulti' Type=Limit Tif=Day Oco='' Filled=0 Fill price=0 Token='5735bec7e0ed4aeaae23b115f025f350' Gtd='12/1/2099 12:00:00 AM'
        2011-05-26 04:31:32:256 (jceVision) Cbi.Connection.ProcessEventArgs.OrderStatusEventArgs: Order='5735bec7e0ed4aeaae23b115f025f350/Sim101' Name='LexitKC 07-11|72|LN 161' New state=PendingCancel Instrument='KC 07-11' Action=BuyToCover Limit price=266.234 Stop price=0 Quantity=3 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
        2011-05-26 04:31:32:256 (jceVision) Cbi.Order.Update1: oldid='5735bec7e0ed4aeaae23b115f025f350' Order='5735bec7e0ed4aeaae23b115f025f350/Sim101' Name='LexitKC 07-11|72|LN 161' New state=PendingCancel Instrument='KC 07-11' Action=BuyToCover Limit price=266.234 Stop price=0 Quantity=3 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
        2011-05-26 04:31:32:256 (jceVision) Cbi.OrderStatusEventArgs.Process: Order='5735bec7e0ed4aeaae23b115f025f350/Sim101' Name='LexitKC 07-11|72|LN 161' New state=PendingCancel Instrument='KC 07-11' Action=BuyToCover Limit price=266.234 Stop price=0 Quantity=3 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
        2011-05-26 04:31:32:569 (jceVision) Cbi.Connection.ProcessEventArgs.OrderStatusEventArgs: Order='5735bec7e0ed4aeaae23b115f025f350/Sim101' Name='LexitKC 07-11|72|LN 161' New state=Cancelled Instrument='KC 07-11' Action=BuyToCover Limit price=266.234 Stop price=0 Quantity=3 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
        2011-05-26 04:31:32:569 (jceVision) Cbi.Order.Update1: oldid='5735bec7e0ed4aeaae23b115f025f350' Order='5735bec7e0ed4aeaae23b115f025f350/Sim101' Name='LexitKC 07-11|72|LN 161' New state=Cancelled Instrument='KC 07-11' Action=BuyToCover Limit price=266.234 Stop price=0 Quantity=3 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
        2011-05-26 04:31:32:569 (jceVision) Cbi.OrderStatusEventArgs.Process: Order='5735bec7e0ed4aeaae23b115f025f350/Sim101' Name='LexitKC 07-11|72|LN 161' New state=Cancelled Instrument='KC 07-11' Action=BuyToCover Limit price=266.234 Stop price=0 Quantity=3 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
        2011-05-26 04:31:32:569 Strategy.StrategyBase.Process.ExpiredOrder: Order='5735bec7e0ed4aeaae23b115f025f350/Sim101' Name='LexitKC 07-11|72|LN 161' State=Cancelled Instrument='KC 07-11' Action=BuyToCover Limit price=266.234 Stop price=0 Quantity=3 Strategy='ProtectDownMulti' Type=Limit Tif=Day Oco='' Filled=0 Fill price=0 Token='5735bec7e0ed4aeaae23b115f025f350' Gtd='12/1/2099 12:00:00 AM'
        I'm wondering if the fact ExpiredOrder() is called after the OnOrderUpdate() might be the issue. Can you guys look into possibly changing the order of some of these calls...? Or internally delay the handling of any new orders generated in OnOrderUpdate(), making sure it only happens after all of the handling of after-effects from the previous order..?

        Comment


          #5
          Heech, I will check with development into but waiting for the cancelled orderstate as you do should be sufficient...and it works for you in most of the cases as I understood, we would just have to isolate what else is contributing in the case you ran into where the order gets ignored. Does that happen in single series strategies, too?

          For the unmanaged mode new in NT7, please see here :

          BertrandNinjaTrader Customer Service

          Comment


            #6
            Thanks. For my purposes, I would've preferred the unmanaged code from day one... but now I have to make a decision whether I should make such a substantial change in my order handling code mid-stream. Probably a worthwhile long time change, in any case.

            Comment


              #7
              By the way, any reason to think "unmanaged" orders won't function correctly (or differently) in back-testing?

              Comment


                #8
                For getting the ultimate flexibility in your order submission, I feel it would be worthwhile switching over - there are some limitations as there's reduced signal tracking so for example EntryHandling / EntriesPerDirection will not work as in managed mode.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by xiinteractive, 04-09-2024, 08:08 AM
                3 responses
                11 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by Johnny Santiago, 10-11-2019, 09:21 AM
                95 responses
                6,193 views
                0 likes
                Last Post xiinteractive  
                Started by Irukandji, Today, 09:34 AM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by RubenCazorla, Today, 09:07 AM
                1 response
                5 views
                0 likes
                Last Post RubenCazorla  
                Started by TraderBCL, Today, 04:38 AM
                3 responses
                25 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X