Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Orders not fully canceled

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

    Orders not fully canceled

    Hi there,

    I'm still working on figuring out some of the odd behaviors behind CancelOrder... this is in reference to version 6.5.1000.17. There are still various times where CancelOrder() doesn't seem to clear Ninja's internal order tracking.

    Meaning:

    - say I have an ExitLongLimit() order...

    - say I later cancel this order using CancelOrder()... (or, at the end of the day the exchange automatically cancels the order)...

    - if, in the same strategy execution, I try to re-submit a ExitLongLimit() order (with the same signal names), NinjaTrader will reject the order while saying "a matching exit order already exists".

    I don't really want to get into the exercise of creating an example, but I will if I have to. I'm just wondering if you guys have any insider tips about what else I can do, on version 6, to "clear" Ninja's internal view of these orders... that would allow me to resubmit.

    #2
    Hello heech,

    This reference sample should help with all the steps needed when using CancelOrder()

    Using CancelOrder() method to cancel orders

    If you issue CancelOrder(), you also need to reset this order object to a null state before trying to submit again.

    protected override void OnOrderUpdate(IOrder order)
    {
    // Checks for all updates to entryOrder.
    if (entryOrder != null && entryOrder.Token == order.Token)
    {
    // Check if entryOrder is cancelled.
    if (order.OrderState == OrderState.Cancelled)
    {
    // Reset entryOrder back to null
    entryOrder = null;

    // Replace entry limit order with a market order.
    mar****rder = EnterLong(1, "market order");
    }
    }
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      I'm already doing this...

      And unless garbage collection is involved some how (and that doesn't make any sense), I don't see how me setting my applications' reference to null or not would affect whether Ninja doesn't allow me to submit another order.

      Comment


        #4
        If I understand how Ninja is designed, there's only a single thread for everything... including events. So, I don't have to worry about possible race conditions in OnOrderUpdate(), do I? Do I need to synchronize access?

        Comment


          #5
          We're not aware of issues in this area. I would evaluate the same strategy with version 7. If you run into anything, please share a simple strategy that we can use to see the issue.


          OnOrderUpdate()

          NinjaTrader is a multi-threaded application and therefore it is extremely important to understand

          This method guarantees that you will see each order state change in sequence
          This method does not provide an update for the most current state of an order but instead provides you an event notifying you of each state change in sequence and the relevant information on the order at the time the state changed
          CRITICAL: If you want to drive your strategy logic based on order fills you must use OnExecution() instead of OnOrderUpdate(). OnExecution() is always triggered after OnOrderUpdate(). There is internal strategy logic that is triggered after OnOrderUpdate() is called but before OnExecution() that can adversely affect your strategy if you are relying on tracking fills within OnOrderUpdate().
          Ryan M.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alifarahani, Today, 09:40 AM
          6 responses
          23 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Kaledus, Today, 01:29 PM
          5 responses
          13 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Waxavi, Today, 02:00 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X