Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitShortStopMarket, ExitLongStopMarket, error Order Rejected, UnableToSubmitOrder

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

    ExitShortStopMarket, ExitLongStopMarket, error Order Rejected, UnableToSubmitOrder

    Hello,

    I'm working on a strategy that gives me the "UnableToSubmitOrder" error for an order of type "ExitShortStopMarket" or "ExitLongStopMarket."

    - The strategy enters with orders like "EnterLong("Long1")" or "EnterShort("Short1")."
    - In the "OnOrderUpdate" method, the order is saved in a variable.
    - In the "OnExecutionUpdate" method, the ProfitTarget and Stop Loss are set using the "ExitShortStopMarket" and "ExitLongStopMarket" orders.
    - Upon entering a trade, the following orders have the following states:
    * Long1: Filled
    * Target1: Working
    * Stop1: Accepted

    So, I have a long position with its corresponding Profit Target and Stop Loss correctly set, which can also be seen on the chart.

    - At a certain point, the price moves very quickly against me, and I get the "UnableToSubmitOrder" error for Stop1, and the state of Stop1 is rejected.
    - The "RealtimeErrorHandling" setting is set to "IgnoreAllErrors" to capture errors.

    1. When the Stop1 order is rejected, what happens to this order? Does it stay in the rejected state, and nothing further happens with that order? Or, once rejected, is it resent by NinjaTrader? or What happens next with this order?
    2. Since Stop1 was in the Accepted state, and the strategy had control over the StopLoss, now that the Stop1 order has been rejected, has Long1 been left without a StopLoss? In other words, can the price move against it, and no order will stop it?
    3.- In fact, before I trying to manage that error, the strategy closes and let me with Long position without Stop Loss
    4. How can I resolve this issue?​

    Thank You

    #2
    I forgot to mention that the TakeProfit orders are made with ExitLongLimit and ExitShortLimit

    Comment


      #3
      Hello ervin,

      Thanks your your post.

      What exactly does the error message in question state so I may accurately assist?

      Is the order being rejected because you are trying to submit it or change it to the wrong side of the market?

      When an order is rejected, it remains rejected until your strategy logic resubmits the order.

      If this is due to market volatility then there isn't really a way to 100% avoid this occurring, as in volatile markets the market could move so far and fast that this would occur.

      Something you could consider is using GetCurrentBid() and GetCurrentAsk() to offset orders so that they are more likely to land on the correct side of the market.

      See these help guide pages for more information.
      GetCurrentBid(): https://ninjatrader.com/support/help...currentbid.htm
      GetCurrentAsk(): https://ninjatrader.com/support/help...currentask.htm

      You could also consider using RealtimeErrorHandling.IgnoreAllErrors to trap order errors in OnOrderUpdate​.

      Please note that setting this property value to IgnoreAllErrors can have serious adverse affects on a running strategy unless you have programmed your own order rejection handling in the OnOrderUpdate() method. To do this you could trap the rejected order by checking if the OrderState is Rejected within OnOrderUpdate() followed by defining your own order rejection handling behavior for the rejected order.

      Please see the example in the help guide link below that demonstrates using RealtimeErrorHandling and trapping a rejected order in OnOrderUpdate().

      RealtimeErrorHandling — https://ninjatrader.com/es/support/h...orhandling.htm
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Thank you for your answer.
        I'm using IgnoreAllErrors like I said in the post. And I'm tring to manage that error in the correct way that is why I'm asing for.
        Like I said in the original post, the original order has been submited and its target and stop established so for the short example I had:
        - EnterShort(Short1) so, I have a Short Position
        - At the execution the Trget and Stop are established with limit and stop orders.
        - and the trade goes on.
        - at this time I have Short1, Target1, and Stop1.
        - the trade go against the short,
        - the strategy just wait for the target or the stop triggered.
        - The prcice move very fast.
        - the error cames up:
        * UnableToSubmitOrder
        * buy order stop price must be above trade price
        these are the error and the messsage.

        GetCurrentBid() and GetCurrentAsk() does not apply because the orders has been alredy set.

        It's the scenario clear? I'm tring to be specific with the situation.

        I have specific questions in the original post, just answer point 1 could you please answer with the aditional information, I copied as follow buy it's for the long example:

        1. When the Stop1 order is rejected, what happens to this order? Does it stay in the rejected state, and nothing further happens with that order? Or, once rejected, is it resent by NinjaTrader? or What happens next with this order?
        2. Since Stop1 was in the Accepted state, and the strategy had control over the StopLoss, now that the Stop1 order has been rejected, has Long1 been left without a StopLoss? In other words, can the price move against it, and no order will stop it?
        3.- In fact, before I trying to manage that error, the strategy closes and let me with Long position without Stop Loss
        4. How can I resolve this issue?​​

        and one more thing:

        When the stop1 is established, the status is Accepted. When price triggered, what are the next states until filled? and what are the states when fails?

        Thank you

        Comment


          #5
          Hello ervin,

          Thanks for your notes.

          If the stop loss is being rejected then the order is rejected and no longer active. It would remain rejected and you would need use RealtimeErrorHandling.IgnoreAllErrors and trap the rejected order in OnOrderUpdate() and submit a new stop loss order.

          The OnOrderUpdate() error code to trap this would be ErrorCode.UnableToSubmitOrder.

          The RealtimeErrorHandling help guide page sample code demonstrates detecting if the OrderState of an order is OrderState.Rejected. After trapping the rejected order you would need to submit a new stop loss order.

          RealtimeErrorHandling: https://ninjatrader.com/support/help...orhandling.htm
          OnOrderUpdate(): ​https://ninjatrader.com/support/help...rderupdate.htm

          The order state of the order could go from Accepted to either Change Submitted, Canceled, Rejected, Part Filled, or Filled depending on what happens to the order.

          Order State Definitions could be found on this help guide page: https://ninjatrader.com/support/help...efinitions.htm
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          41 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X