Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Oder stop price must be above trade price

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

    Oder stop price must be above trade price

    Hello, I have created a strategy that works on the breakout of the candles by placing a stop market order on the high of the candle at the close of the candle. The strategy works well but unfortunately every now and then it happens that the candle closes very close to highs and the positioning of the order by the strategy generates the error "... buy order stop price must be above trade price affected Order."
    I entered the code to keep the strategy working but I would like to ask if it is possible to intercept the error and when this happens, enter a market order in order to take a few ticks of slippage but avoid the trade not being executed.
    Many thanks in advance​

    #2
    Thank you so much StephenGlover very helpful!!! I have one question about it. Does the try function continue to place the order if obviously the price is lower but is the order definitively canceled if not triggered within the next candle?

    Comment


      #3
      and the system tells me that there is no WaitForFill function

      Comment


        #4
        Hello mmmf84,

        Thanks for your post.

        You could use the workaround that StephenGlover suggested. Note that WaitForFill() mentioned by StephenGlover is a custom method and not one that comes default in NinjaScript. StephenGlover may provide more insight on how this custom method is created and used.

        You may consider using RealtimeErrorHandling to determine the behavior of a strategy when the strategy places an order that is returned "Rejected". The default behavior is to stop the strategy, cancel any remaining working orders, and then close any open positions.

        RealtimeErrorHandling could be set to IgnoreAllErrors to ignore any order errors received or StopCancelCloseIgnoreRejects to perform the default strategy behavior on all errors except order rejections. 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

        Let me know if I may assist further.​
        <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, Yesterday, 05:17 AM
        0 responses
        65 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        139 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X