Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't sell under market price or viceversa

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

    Can't sell under market price or viceversa

    Sometimes using little stop loss or take profit it happens that it gives me the error attached. But if i use bigger stop loss or take profit there is no problem. For the tp and sl i'm just using the set stop loss and set take profit. How can i manage to not have this error? I know i could do a check for the price and ecc, the problem is that i set tp and sl, (managed way) then i use Enterlong/shortLimig(parameters) and when the order is touched it opens the position and instantaneuosly set the tp and the sl from what i decided before. the problem is ofcourse that i don't know when this happens and i don't think there is a way to manage that. thanks
    Attached Files

    #2
    Hello AlessioCianini12,

    The error is letting you know the stop order was placed in the wrong side of the market. As the order is placed, if its placed too close the current price the price can move just as the order is submitted and cause the order to be on the wrong side.

    Buy stop orders must be 1 tick above the ask, sell stop orders must be 1 tick below the bid.

    To prevent the error in a fast moving market, choose a price either higher above the ask or lower below the bid.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Excuse me but what if i want to use just 1tik? shouldn't be normal that if the order doesn't hit the price it fills as a market order?

      Comment


        #4
        Hello AlessioCianini12,

        Stop Market orders will get rejected if they are on the other side of the market by the time they are processed. If your stop loss has 1 tick of distance from the entry, the market only has to move one tick by the time the order gets processed and then the stop loss would land on the other side of the market. We would then get the rejection.

        When the stop loss gets rejected, the OCO ID becomes invalid, and the Profit Target order cannot be accepted.

        The solution is to increase the distance of the stop loss, or you could consider implementing RealtimeErrorHandling code to handle the rejection, close the position, and keep the strategy running.

        For example, you could use RealtimeErrorHanlding.StopCancelCloseIgnoreRejects , and then in OnOrderUpdate, you could check for orders that have an OrderState of OrderState.Rejected. If you see a rejection for your stop loss order in OnOrderUpdate, you could consider calling ExitLong/ExitShort to close the position.

        RealtimeErrorHandling

        To prevent the strategy from being deactivated when an order error occurs, you can set the strategy's RealtimeErrorHandling property to IgnoreAllErrors. StopCancelCloseIgnoreRejects will keep the strategy running for rejections but not for other order errors like a failure to change an order. With this property set, you can then trap order errors in OnOrderUpdate if you would like to have the strategy attempt a different action.

        Please note that this is reserved for advanced uses that want to implement their own order error handling. Neglecting to handle an order error when having RealtimeErrorHandling set to IgnoreAllErrors or StopCancelCloseIgnoreRejects can result in damages to your account. ALWAYS monitor your automated trading strategies.

        RealtimeErrorHandling - https://ninjatrader.com/support/help...orhandling.htm

        OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        64 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