• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Catch Order Error

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

    Catch Order Error

    After sending the wrong parameters to 'SubmitOrderUnmanaged' I recieved the following errors to the screen and log. Is there a way to catch those errors in my code and handle them there instead of GUI/system log?

    Thanks


    Time Category Message
    14/11/2018 18:38:51 Order Sim101, Order '1c5f41ede9a74ba8b5ca10b2daab5428' can't be submitted: The OCO ID ‘OCO_004’ cannot be reused. Please use a new OCO ID. affected Order: Sell 13 StopMarket @ 1.793
    Time Category Message
    14/11/2018 18:38:51 Default Strategy 'OrderTransferSingle/141062892' submitted an order that generated the following error 'Unable to submit order'. Strategy has sent cancel requests, attempted to close the position and terminated itself.

    #2
    Hello kiss987,

    You can detect the rejection and prevent the script from being disabled, but I'm not aware of a way to get the actual native rejection message.

    Set RealtimeErrorHandling to RealtimeErrorHandling.IgnoreAllErrors.

    Then detect the order's OrderState to be OrderState.Rejected.

    Below are public links to the help guide.
    https://ninjatrader.com/support/help...orhandling.htm
    https://ninjatrader.com/support/help...rderupdate.htm
    https://ninjatrader.com/support/help...n-us/order.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply.

      Is there a way to keep the default behavior (stop strategy and flatten everything) and at the same time catch the error by code?

      Comment


        #4
        Hello kiss987,

        Unfortunately, if the script becomes disabled due to an error it is no longer running and OnOrderUpdate is no longer triggered.

        You could instead make a separate addon that monitors the account orders.
        Below are public links to the help guide.
        https://ninjatrader.com/support/help...ount_class.htm
        https://ninjatrader.com/support/help...rderupdate.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi

          I do understand the logic of the code, however I don't understand how add ons are generally works. How do I use the MyAddOnTab add-on?

          Comment


            #6
            Hello kiss987,

            I'm not certain what the MyAddOnTab script is. Is this downloaded from the NinjaTrader Help Guide?
            May I have a link?

            Addons are outside of the indicator and strategy classes but have access to general NinjaScript tools. These in general build their own windows (or are used as libraries called from other scripts that don't have their own window). The OnWindowCreated() event handler allows you to add menu items to the New menu of the Control Center when the Control Center window is created.
            When clicking the menu item, this creates and shows an instance of the addon window.

            Below is a link to an example.
            https://ninjatrader.com/support/foru...830#post759830
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Lancer, Today, 10:39 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by koganam, Today, 10:33 AM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by FREEN, Today, 10:17 AM
            2 responses
            7 views
            0 likes
            Last Post FREEN
            by FREEN
             
            Started by stoner, Today, 08:38 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by retrobeast, Today, 08:13 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Melissa  
            Working...
            X