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

Unmanaged approach: RealtimeErrorHandling

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

    Unmanaged approach: RealtimeErrorHandling

    This is in the help guide:

    Defines the behaviour of a strategy when a strategy generated order is returned from the broker's server in a "Rejected" state. Default behaviour is to stop the strategy, cancel any remaining working orders, and then close any open positions managed by the strategy by submitting one "Close" order for each unique position.
    1. If I work under unmanaged order method, can I trust that the default behaviour will be executed as said above ? or must I code the whole logic ?

    2. Despite the default state, I've tried to set in the Initialize method this:

    protected override void Initialize()
    {
    RealtimeErrorHandling=RealtimeErrorHandling.StopSt rategyCancelOrdersClosePosition;
    }

    But it creates a compilation error; however the alternative RealtimeErrorHandling.TakeNoAction was just fine; so is this cause the default state doesn't need to be stated ?

    Thanks

    #2
    Hi Pstrusi,

    Yes, this is the expected default behavior of the RealTimeErrorHandling.

    What is the compile error you are receiving?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      1)
      the name 'stopstrategycancelorderscloseposition' does not exist in the actual context
      2)
      'ninjatrader.strategy.realtimeerrorhandling' does not have a definitinion of 'stopstrategycancelorderscloseposition' or any other extension method found. 'stopstrategycancelorderscloseposition' does not accept the fist argument 'ninjatrader.strategy.realtimeerrorhandling' a directive is missing or assambly reference

      Comment


        #4
        Pstrusi,

        There is no need to use the StopStrategy as this is the default property with the NinjaScript.

        It will automatically do this function unless you tell it to TakeNoAction.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by pstrusi View Post
          1)


          2)
          Are your quotes here EXACT? Including case? Is that exactly how the error message is being returned, case and all?

          Comment


            #6
            Nope, the error message was a mix of English and Spanish words. I've tried to translate in the most faithful way the few words of spanish to english.

            Here you go:

            'NinjaTrader.Strategy.RealtimeErrorHandling' no contiene una definición de 'StopStrategyCancelOrdersClosePosition' ni se encontró ningún método de extensión 'StopStrategyCancelOrdersClosePosition' que acepte un primer argumento de tipo 'NinjaTrader.Strategy.RealtimeErrorHandling' (żfalta una directiva using o una referencia de ensamblado?)

            Comment


              #7
              Originally posted by NinjaTrader_Cal View Post
              Pstrusi,

              There is no need to use the StopStrategy as this is the default property with the NinjaScript.

              It will automatically do this function unless you tell it to TakeNoAction.
              Cal, what if the error for an order is not rejected, but any of this:

              ErrorCode.BrokerOrderError
              ErrorCode.InvalidInstrument
              ErrorCode.LoginFailed
              ErrorCode.NoError
              ErrorCode.NotConnected
              ErrorCode.NotSupported
              ErrorCode.Panic
              ErrorCode.ServerConnectionIsBroken
              ErrorCode.UnableToCancelOrder
              ErrorCode.UnableToChangeOrder
              ErrorCode.UnableToSubmitOrder
              ErrorCode.UserAbort

              NT will handle any of those situation as the same as it was order rejected ? or must I code a different logic for it?

              Comment


                #8
                Pstrusi,

                The RealtimeErrorHandling is only going to function when a Rejected order state gets returned by the broker. These other errors are not handled by this function and therefore won't kick in the the handling.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Cal View Post
                  Pstrusi,

                  The RealtimeErrorHandling is only going to function when a Rejected order state gets returned by the broker. These other errors are not handled by this function and therefore won't kick in the the handling.
                  1. What happens with the Script if any of non-rejected error occurs ? will my Script be disabled ? Will the system resend the order until being get accepted or rejected ?

                  2. If I decided to do a little snippet that confirms that there is not any of this error before continuing, how would I call them in a generic form ? I see there's Error=NoError and Native error='' I've read in the forum that someone call it like this: if (order.NativeError == "ErrorCode.Panic") But ErrorCode.Panic is just one of them

                  Thanks

                  Comment


                    #10
                    Pstrusi,

                    Only an Order Rejection will cause the Strategy to shutdown.

                    If you go to your script you can type in ErrorCode.

                    After the dot the Intellisense will show a drop menu next to it and display the available error codes.
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Cal, thanks for your response.

                      I've taken note of the intellisense hint but I really like to know the answers for the this question:

                      1. If any of the non-rejected error occurs will the system resend the order until being get accepted or rejected, or will this order automatically be deactivated after any of those errors?

                      Comment


                        #12
                        Pstrusi,

                        If any of the non-rejected error occurs will the system resend the order until being get accepted or rejected, or will this order automatically be deactivated after any of those errors?
                        No to both questions.

                        There are only three scenarios that you need to account for with working Unmanaged orders -
                        Overfills, Order Rejections and Connection Loss

                        This is discussed in the last section of the link below -
                        http://www.ninjatrader.com/support/h...d_approach.htm
                        Cal H.NinjaTrader Customer Service

                        Comment


                          #13
                          Cal it can't be NO for the two opposite questions. If any of these errors happens, the order will be stay live or be cancelled by the system; that's what I want to know. So besides of the well known three scenarios Overfills, Order Rejections and Connection Loss, what happens to an order that is returned with a temporal error from the broker?

                          Comment


                            #14
                            Pstrusi,

                            An order will only be handled internally, when it gets rejected. Those other error codes do not effect the RealtimeErrorHandling that way.

                            If an error comes back that is Non-rejected, the order will stay as it is or will get resubmitted when the condition is true again for the entry order.

                            The only time a strategy handles any error is when the Order gets rejected and you have the default RealtimeErrorHandling (StopStrategyCancelOrdersClosePositions).

                            Furthermore, I'm not sure what you mean by temporal error form the broker, could you please elaborate?
                            Cal H.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks Cal for the clear answer, now I already know how the logic must continue.

                              I'm sorry about "temporal error from the broker, it was just another way to reference to any of those error messages that might come from the broker.

                              Thanks for your patience and help.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by arvidvanstaey, Today, 02:19 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post arvidvanstaey  
                              Started by mmckinnm, Today, 01:34 PM
                              3 responses
                              5 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by f.saeidi, Today, 01:32 PM
                              2 responses
                              6 views
                              0 likes
                              Last Post f.saeidi  
                              Started by alifarahani, 04-19-2024, 09:40 AM
                              9 responses
                              55 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by Conceptzx, 10-11-2022, 06:38 AM
                              3 responses
                              60 views
                              0 likes
                              Last Post NinjaTrader_SeanH  
                              Working...
                              X