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

Insufficient Buying Power

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

    Insufficient Buying Power

    How can I know if my order was not filled due to Insufficient Buying Power?

    Thanks

    #2
    Hello kiss987,

    Thanks for your post.

    If there was a lack of margin there would be a pop-up window from NinjaTrader advising you that the order was rejected and why. The error would also appear in the "log" tab of the control center and in the log//trace files of the day.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello
      I meant how can I know by code and not visually that this is the reason.
      Another questions: In the case of Insufficient Buying Power, will my strategy will stop?

      Thanls

      Comment


        #4
        Yes, your strategy should stop.

        Had this happen in nt8 when i ran out of $100,000.

        Comment


          #5
          Hello
          I meant how can I know by code and not visually that this is the reason.

          Comment


            #6
            Originally posted by kiss987 View Post
            Hello
            I meant how can I know by code and not visually that this is the reason.
            Compute it before you make the trade?



            After the trade it is impossible as the strategy is disabled. No code is going to run.

            Comment


              #7
              Hello kiss987,

              Thanks for you reply.

              Member sledge is correct your strategy will stop on error messages.

              There is no internal support for bringing in provider error messages to your strategy. Not all providers use the same messages. All that you would know, in code, is that the order has been rejected.

              You can monitor your account in your strategy which includes Buying power: http://ninjatrader.com/support/helpG...countvalue.htm
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Will closing my strategy would also automatically close all my positions and clear all my orders?

                Thanks

                Comment


                  #9
                  Originally posted by NinjaTrader_Paul View Post
                  There is no internal support for bringing in provider error messages to your strategy
                  Not sure I'd completely agree with that statement.

                  In NT7, I would add the following to Initialize,

                  Code:
                  // strategy will handle OrderRejected errors itself
                  RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
                  Then I check for rejected orders in OnOrderUpdate,

                  Code:
                  if (order.OrderState == OrderState.Rejected)
                  {
                    // handle error here
                  }
                  To further detect the reason for the order rejected error, I look at the string property called NativeError, documented here:



                  The NativeError string property is defined as "A string representing the error message provided directly from the broker".

                  I was surprised to discover that NT8 no longer provides access to this error message in the 'Order' object. This seemed like a step backwards. However ...

                  In NT8, I found the NativeError message does still appear to be available -- it is now passed as the last argument to the NT8 OnOrderUpdate method, documented here,



                  I haven't upgraded my strategies to NT8, yet, but when I do, it looks like my plan of action will be:

                  1. Set 'RealtimeErrorHandling' to RealtimeErrorHandling.IgnoreAllErrors in State.Configure.

                  2. If OrderState == OrderState.Rejected in OnOrderUpdate, then interpret the last argument as the error message from the broker (aka NativeError).

                  I think Paul is being a little pedantic by saying 'no internal support' when he might really be meaning to say 'minimal support' -- I mean, clearly, there is some support, unless I am missing something ...

                  Paul? Patrick?

                  Comment


                    #10
                    Originally posted by NinjaTrader_Paul View Post
                    There is no internal support for bringing in provider error messages to your strategy. Not all providers use the same messages. All that you would know, in code, is that the order has been rejected.
                    Sorry, I didn't follow my point to its logical conclusion.

                    My first point was this: When an order is rejected, the error message from his broker is most certainly available. See my previous post.

                    My second point is this:
                    OP could do a bit of hard-coding here. I mean, even if the error messages are different from all providers, chances are the error message from his provider for this issue is consistently the same. So, OP should take advantage of that fact, and specifically look for that specific error message.

                    Unless OP is building a strategy that needs to be multi-provider aware, OP doesn't need to care so much about all the varying error messages -- just the one he sees from his provider.

                    Comment


                      #11
                      Hello bltdavid,

                      Thanks for your replies.

                      I agree with your posts and thank-you for your clarifications and contributions.

                      To the OP I would also offer that it is important to understand that setting the real time error handling to "take no action" means that the strategy will no longer: "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."

                      The helpguide also offers this caution: "Setting this property value to "TakeNoAction" can have *serious* adverse affects on a running strategy unless you have programmed your own order rejection handling in the OnOrderUpdate() method
                      • User defined rejection handling is advanced and should *only* be addressed by experienced programmers"


                      Please review the full helpguide section here: http://ninjatrader.com/support/helpG...orhandling.htm
                      Paul H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by terofs, Yesterday, 04:18 PM
                      1 response
                      21 views
                      0 likes
                      Last Post terofs
                      by terofs
                       
                      Started by CommonWhale, Today, 09:55 AM
                      1 response
                      3 views
                      0 likes
                      Last Post NinjaTrader_Erick  
                      Started by Gerik, Today, 09:40 AM
                      2 responses
                      7 views
                      0 likes
                      Last Post Gerik
                      by Gerik
                       
                      Started by RookieTrader, Today, 09:37 AM
                      2 responses
                      12 views
                      0 likes
                      Last Post RookieTrader  
                      Started by alifarahani, Today, 09:40 AM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Working...
                      X