Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is there a way to handle Order Cancelled?

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

    Is there a way to handle Order Cancelled?

    Hello,

    I could not find an Order.State == Cancelled. When I run my strategy, at times, the order is cancelled and an entry opportunity is missed.

    Qs:
    1. What would cause this? The entry price is 2 ticks above the last price (long). The profit target is 4 ticks away, and stop loss is 8 ticks away. So none of them are too close to the entry price to collide.
    2. I notice also NT says order is cancelled when in fact it has reached the profit target. It doesn't say Target Filled, but rather Cancelled, even so the position is filled and closed at the profit target.

    I would like to handle the case where an order is cancelled and an entry is missed. Would be good to know why, but more important is I'd like to resubmit the order. Is it due to the price has moved to another bar?

    Many Thanks, Caesar.

    #2
    Hello Caesar,

    Where you have asked:
    What would cause this?
    What are you referring to by 'this'?
    Are you asking why the order cancellation did not trigger OnOrderUpdate() with OrderState.Cancelled?

    Are you asking why the order was cancelled?
    Are you cancelling the order with CancelOrder()?
    Is this the managed approach and the order is being automatically cancelled due to liveUntilCancelled false, as shown the TraceOrders messages?
    Is the order an OCO order and the opposing order filled?

    If an order submitted by a strategy was cancelled and did not trigger OnOrderUpdate() with OrderState.Cancelled, I will need to see evidence of this. Please provide a reduced test script that can produce the behavior, has TraceOrders enabled, and prints the order.OrderState in OnOrderUpdate().

    I notice also NT says order is cancelled when in fact it has reached the profit target. It doesn't say Target Filled, but rather Cancelled, even so the position is filled and closed at the profit target.
    Are you certain this is same order with the same ID?
    Are you printing the order object in OnOrderUpdate showing the ID of the order?
    No other order was filled to exit the position? (Perhaps an OCO order?)

    I would like to handle the case where an order is cancelled and an entry is missed.
    This is done in OnOrderUpdate() by checking the order.OrderState == OrderState.Cancelled.
    The help guide has sample code of checking an orders orderstate.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Caesar,

      Where you have asked:

      What are you referring to by 'this'?
      Are you asking why the order cancellation did not trigger OnOrderUpdate() with OrderState.Cancelled?
      Yes, I just found it.Thanks.

      Originally posted by NinjaTrader_ChelseaB View Post
      Are you asking why the order was cancelled?
      Are you cancelling the order with CancelOrder()?
      The order is cancelled by the system.
      Yes, there doesn't seem to be any reason for the cancellation.

      Originally posted by NinjaTrader_ChelseaB View Post
      Is this the managed approach and the order is being automatically cancelled due to liveUntilCancelled false, as shown the TraceOrders messages?
      I don't know anything about liveUntilCancelled, what is the default behaviour?
      The order was submitted by EnterLongLimit.

      Originally posted by NinjaTrader_ChelseaB View Post
      Is the order an OCO order and the opposing order filled?
      [/quote/

      No, just a simple EnterLong/Short.

      Originally posted by NinjaTrader_ChelseaB View Post
      If an order submitted by a strategy was cancelled and did not trigger OnOrderUpdate() with OrderState.Cancelled, I will need to see evidence of this. Please provide a reduced test script that can produce the behavior, has TraceOrders enabled, and prints the order.OrderState in OnOrderUpdate().


      Are you certain this is same order with the same ID?
      Are you printing the order object in OnOrderUpdate showing the ID of the order?
      No other order was filled to exit the position? (Perhaps an OCO order?)


      This is done in OnOrderUpdate() by checking the order.OrderState == OrderState.Cancelled.
      The help guide has sample code of checking an orders orderstate.
      https://ninjatrader.com/support/help...rderupdate.htm
      As I wasn't aware of OrderState.Cancelled, I'll have to code this up.

      Many Thanks Chelsea!

      Comment


        #4
        Hello Caesar,

        To confirm, you have enabled TraceOrders?
        What is the message from TraceOrders when the order is cancelled?

        EnterLongLimit() would be using the managed approach and would be automatically cancelled if isLiveUntilCancelled is not set to true.

        EnterLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName)
        EnterLongLimit(0, true, 1, Low[0] - 3 * TickSize, "myLimitEntry");

        "Parameters
        isLiveUntilCancelled The order will NOT expire at the end of a bar, but instead remain live until the CancelOrder() method is called or its time in force is reached.​"
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          No, I have not enabled TraceOrder, something new for me to learn, I'm very much a novice with NT8. So far it's been great, I like the preciseness of C#.

          Many Thanks for the TraceOrders tip, Caesar.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          44 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X