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

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.


    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.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Tim-c, Today, 10:58 AM
            0 responses
            1 view
            0 likes
            Last Post Tim-c
            by Tim-c
             
            Started by traderqz, Yesterday, 09:06 AM
            3 responses
            21 views
            0 likes
            Last Post NinjaTrader_ThomasC  
            Started by f.saeidi, Today, 10:19 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by kujista, Today, 06:23 AM
            5 responses
            18 views
            0 likes
            Last Post kujista
            by kujista
             
            Started by traderqz, Today, 12:06 AM
            3 responses
            6 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X