Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    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 kujista, Today, 05:44 AM
      0 responses
      5 views
      0 likes
      Last Post kujista
      by kujista
       
      Started by ZenCortexCLICK, Today, 04:58 AM
      0 responses
      7 views
      0 likes
      Last Post ZenCortexCLICK  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      172 responses
      2,281 views
      0 likes
      Last Post sidlercom80  
      Started by Irukandji, Yesterday, 02:53 AM
      2 responses
      18 views
      0 likes
      Last Post Irukandji  
      Started by adeelshahzad, Today, 03:54 AM
      0 responses
      8 views
      0 likes
      Last Post adeelshahzad  
      Working...
      X