Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Submitted an order that generated the following error 'Unable to cancel order'

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

    Submitted an order that generated the following error 'Unable to cancel order'

    Could someone help me to resolve this above error related to CancelOrder()?
    At 3:52:09, from my own logs, it shows after an cancel order was submitted, its state became "Accepted"-> "Working"
    The code has been repeating "Submit" and "Cancel" based on condition changes.

    Here are the sequences of the information leading to the errors:

    3:40:09 order state='Submitted' Instrument
    3:40:09 order state='Accepted' Instrument
    3:40:09 order state='Working' Instrument
    3:42:09 order state='Cancel Submitted' Instrument
    3:42:09 order state='Cancelled' Instrument
    ...

    3:50:09 order state='Submitted' Instrument
    3:50:09 order state='Accepted' Instrument
    3:50:09 order state='Working' Instrument
    3:52:09 order state='Accepted' Instrument
    3:52:09 order state='Working' Instrument
    3:52:09 order An error occurred while sending the request. affected Order : Buy 100 Limit @ 20.18
    3:52:09 default submitted an order that generated the following error 'Unable to cancel order'

    3:52:19 Default Strategy 'XX' submitted a cancellation request for Order ID ...
    Last edited by localappleseed; 11-04-2020, 06:16 PM.

    #2
    Hello localappleseed,

    Thanks for your post.

    When a strategy receives an order error like Unable To Cancel, the strategy will be disabled, NinjaTrader will attempt to cancel orders, and attempt to close the strategy position. Custom order error handling can be done when setting RealtimeErrorHandling to IgnoreAllErrors will allow you to trap the order errors in OnOrderUpdate if you would like the strategy to react differently and stay running. (You would check for orders that have an ErrorCode of UnableToCancelOrder in OnOrderUpdate to trap those order errors.)

    Why the order would be unable to cancel is most often when the order is in the process of filling, or is already in the processes of canceling. An order modification or a replacement at the exchange involves canceling and replacing the order, so we can see these types of order errors simply due to the timing in which the cancel was submitted.

    We would not be able to give further insight if that was the case without reviewing your log and trace files. You may send me your log and trace files in an email message to platformsupport [at] ninjatrader [dot] com with the text "Attn Jim 2820547" and a link to this thread. In addition to the log and trace files, please let me know the instrument that was being traded, the date, and the associated Order ID.

    Attaching Log and Trace files

    Please follow the steps below to manually attach your log and trace files to your response so I may investigate this matter further.
    • Open your NinjaTrader folder under My Documents.
    • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
    • Send the 2 compressed folders as attachments to an email to me.
    • Once complete, you can delete these compressed folders.
    More information on RealtimeErrorHandling can be found below.

    RealtimeErrorHandling

    To prevent the strategy from being deactivated when an order error occurs, you can set the strategy's RealtimeErrorHandling property to IgnoreAllErrors. StopCancelCloseIgnoreRejects will keep the strategy running for rejections but not for other order errors like a failure to change an order. With this property set, you can then trap order errors in OnOrderUpdate if you would like to have the strategy attempt a different action.

    Please note that this is reserved for advanced uses that want to implement their own order error handling. Neglecting to handle an order error when having RealtimeErrorHandling set to IgnoreAllErrors or StopCancelCloseIgnoreRejects can result in catastrophic damages to your account. ALWAYS monitor your automated trading strategies.

    RealtimeErrorHandling - https://ninjatrader.com/support/help...orhandling.htm

    OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

    We look forward to assisting.

    Comment


      #3
      Thanks, Jim, for your detailed information. I agree with you the timing could be the cause most likely as this happens randomly. I will try to remedy the logics to my strategy to see it helps. Otherwise I would send you more detailed logs for further analysis. Thanks again.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      43 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