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 sjsj2732, Yesterday, 04:31 AM
          0 responses
          30 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          286 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          282 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          132 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          90 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X