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

Invalid orders should be rejected so user can act on error

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

    Invalid orders should be rejected so user can act on error

    When a stop order is close to current price, it can be flagged as an error by NT, which may in turn kill the strategy. While I understand the reasoning for flagging the order, a better approach would be to return an order reject, which would allow the strategy to act on the bad order (i.e. go market instead of using a stop). This would be more consistent with the normal process as well, as an order might not be flagged by NT, but will be flagged by brokerage because price has moved during that short time frame.

    This is more of an issue in backtest, where bar by bar processing can make it difficult to submit a valid order due to event ordering. It would be nice if it worked similar to the RealtimeErrorHandling where these errors can be ignored. By returning the order reject and NT ignoring the error, the strategy would have the opportunity to recover even in backtest.

    Why is an order reject not used to signify a bad order entry?

    #2
    Hello aslane,

    If desired it would be possible to allow the strategy to continue running and require the user to place an order or click a button or whatever you would like.

    The default behavior is to stop the script and cancel all orders and close positions as most strategies are not written in a manner the logic is prepared to managed a rejected order.

    When you mention:
    "Why is an order reject not used to signify a bad order entry?"

    An order being rejected could be an entry or an exit order such as an exit stop market order with an invalid stop price or could be rejected due to low margin with the brokerage account.

    As a rejected order is not always an entry order, the order may not be a bad order entry.

    The strategy can be written to continue running and could also try and resubmit an order with a valid price or prevent orders until a message is acknowledged.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Ok I should have said "bad order submission" vs entry. So, why is an order reject not issued for a bad order submission?

      The specific cases I am talking about are submitting a stop order in response to OnExecutionUpdate or submitting an entry order. If they are too close to the market, you will get msgs like:

      Strategy 'XXX/-1': A Buy order placed at '3/12/2019 9:30:00 AM' has been ignored since the stop price is less than or equal to the close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.

      When this happens, the strategy typically stops, but not always. When it does not stop, there is not indication from NT that the order was in error.

      I also should have mentioned that this is with unmanaged orders if that makes a difference.

      The reject would allow the strat to respond to the error accordingly.

      Comment


        #4
        Hello aslane,

        Orders that are never submitted, and are completely ignored, do not get rejected by the brokerage because they are never submitted to the brokerage.

        An ignored order will not cause the strategy to become disabled but will cause a message to appear when TraceOrders is enabled in the NinjaScript Output window.

        Ignored orders do not qualify as an error that would be handled by the order error handling.

        This also does not cause OnOrderUpdate() or OnExecution() to trigger as no order is ever initialized. (This is not subject to in-flight price changes either as the order is not submitted)

        With this specific error, the script should be corrected to not attempt to use an invalid stop price at the time of submission. Buy stop orders must have the stop price above the current ask, sell stop orders must be below the current bid.

        To confirm, you are requesting that ignored order messages generate the order anyway and trigger order methods with the order state as rejected, is this correct?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ok, one item I just realized is that when this error happens, the Order returned from SubmitOrderUnmanaged is null. So, there is an indication of error. Generally, I have ignored that value because I capture the order later in OnOrderUpdate.

          I can work with the null return. However, is there any way to not get the log message?

          Comment


            #6
            Hello aslane,

            I'm not aware of a way to capture ignored order messages.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Ok, and that's why using an order reject instead of ignoring the order would make everything logical and fit into the normal flow.

              Comment


                #8
                Hello aslane,

                To confirm, you are requesting that ignored order messages generate the order anyway and trigger order methods with the order state as rejected, is this correct?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  That is correct.

                  Comment


                    #10
                    Hello aslane,

                    Thank you for your patience.

                    I'm responding on behalf of Chelsea, who is out of the office today. This request is being tracked under the number SFT-4338.

                    As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

                    Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

                    Please let us know if we may be of further assistance to you.
                    Kate W.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by ScottWalsh, 04-16-2024, 04:29 PM
                    7 responses
                    34 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by cls71, Today, 04:45 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post cls71
                    by cls71
                     
                    Started by mjairg, 07-20-2023, 11:57 PM
                    3 responses
                    214 views
                    1 like
                    Last Post PaulMohn  
                    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                    4 responses
                    544 views
                    0 likes
                    Last Post PaulMohn  
                    Started by GLFX005, Today, 03:23 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post GLFX005
                    by GLFX005
                     
                    Working...
                    X