Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to cancel order?

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

    How to cancel order?

    I need to cancel an entry order.

    Is it enough to send a cancel request or I need to check OrderState and to send cancel request / close order, depending on order state?

    I read in NinjaTrader help that "CancelOrder() does not guarantee that an order is completely cancelled." What additional steps should I take to make sure that the order is completely cancelled / closed?

    Thanks,

    Valentin

    #2
    Hello Valentin,

    Thanks for your post.

    You can test .OrderState == OrderState.PendingCancel as well as or just .OrderState == OrderState.Cancelled in OnOrderUpdate() http://www.ninjatrader.com/support/h...rderupdate.htm

    Comment


      #3
      Thank you Paul,

      Currently I test Position.MarketPosition == MarketPosition.Flat in OnBarUpdate() to know whether previous position is closed.

      I suppose that when order is cancelled, market position will be flat, so I can use it as a condition for the new entry. Is it correct?

      What will be market position while .OrderState == OrderState.PendingCancel?

      Is it OK to use Position.MarketPosition == MarketPosition.Flat as a condition for the new entry, in case that some orders will be closed and other orders will be cancelled?

      Valentin

      Comment


        #4
        Hello Valyo,

        Thanks for your reply.

        Yes, using checking Market.Position is a good practice when you wish to enter from a flat position.

        If the order has not been cancelled then you would not be flat.

        Comment


          #5
          Great. So everything is OK. Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          65 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X