Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CancelOrder does not work, CancelAllOrders does

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

    CancelOrder does not work, CancelAllOrders does

    I'm creating an order and then attempting to cancel it. I create the order like this:

    _order = EnterLongLimit(DefaultQuantity, price, "");

    where _order is a member variable in my strategy. At a later point (after the state becomes OrderState.Working) I call this:

    CancelOrder(_order);

    but the order is never cancelled. If I replace the call to CancelOrder with one to CancelAllOrders(true, true) then the order is cancelled as expected. I'm in Managed mode. Any ideas?

    #2
    Hello endian675,

    It sounds like you're doing things correctly and nothing stands out yet. Are there any errors in the log tab when you run this? Would the conditions still be valid for the order to be submitted when you send the cancel?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      No errors in the log tab, no. I've cut the strategy down so that all it does is submit an order with _order = EnterLongLimit(xxxx), and then in OnOrderUpdate(), when the state == OrderState.Working, calls CancelOrder(_order). So it's not an order being resubmitted, simply nothing ever happens. When I cancel the order manually from the DOM I can see the state changes happening correctly (PendingCancel, Cancel). I'm on NT7 64-bit, 7.0.1000.8.

      Here's the output from my strategy/TraceOrder:

      Code:
      19/01/2012 07:44:20 Entered internal PlaceOrder() method at 19/01/2012 07:44:20: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=2395 StopPrice=0 SignalName='' FromEntrySignal=''
      EnterLongLimit(2395),orderId,401b5d7bd43241a9b121a8e653eaf0b3,07:44:20
      Starting timer
      OOU,401b5d7bd43241a9b121a8e653eaf0b3,PendingSubmit
      OOU,401b5d7bd43241a9b121a8e653eaf0b3,Accepted
      OOU,401b5d7bd43241a9b121a8e653eaf0b3,Working
      OOU, Cancelling,401b5d7bd43241a9b121a8e653eaf0b3
      OOU = OnOrderUpdate. As you can see, even though CancelOrder is called with the correct IOrder, the cancel never takes place. When I manually cancel the order from the DOM I get this output from the strategy:

      Code:
      OOU,401b5d7bd43241a9b121a8e653eaf0b3,PendingCancel
      OOU,401b5d7bd43241a9b121a8e653eaf0b3,Cancelled
      Last edited by endian675; 01-19-2012, 01:48 AM.

      Comment


        #4
        OK, I think I've found the problem. I was calling EnterLongLimit(limitPrice), which submits an order that is live until the end of the bar. Now that I'm calling with liveUntilCancelled=true I can call CancelOrder() as expected.

        Personally I think it's a bit odd that I can't call CancelOrder() on a liveUntilCancelled=false order, since I might want to have an order that is cancelled automatically at the end of the bar, or by me beforehand.

        Comment


          #5
          OK, glad you were able to get it sorted out. Thanks for updating us here.

          To code for the "cancel on every bar" behavior for liveUntilCancelled orders, you could monitor for FirstTickOfBar event and cancel then.
          Ryan M.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          574 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X