Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order cannot enter because price moved too fast

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

    Order cannot enter because price moved too fast

    My code looks at the prior candle, and if the current candle has retraced inside the prior candle it will set a stop limit order to trigger when the range is broken depending on long or short. Below is a snippet of the code for a short. It works like 95% of the time, but occasionally i get an error that the limit cant be placed below or above the market. Since i have the criteria which checks the current price is above the limit value, i can only assume this is happening because price moved too quickly in that spot, that by the time the limit order was submitted it had already moved back out of range.

    Is there anyway to address this?

    Some ideas are the have price a certain number of ticks back within the range before the condition is met? Or a certain amount of time before condition is met?

    These don't seem elegant and seem like a bad crutch i guess.

    Lastly, the strategy is stopped everytime i run into one of these errors, if no solution for the above, is there at least a way to ignore that type of error and keep running the strategy?



    Code:
    if (isPossibleShort && Close[0] > _indicatorCandleLowForShort)
    {
    Print(Time[0] + " Create Limit Short");
    EnterShortPosition();
    isIndicatorCandleFired = false;
    isPossibleShort = false;
    
    EnterShortStopLimit(NumberOfContracts, limitPrice, stopPrice, "ShortOrder");
    SetProfitTarget("ShortOrder", CalculationMode.Price, tpPrice);
    SetStopLoss("ShortOrder", CalculationMode.Price, _indicatorCandleHighForShort, true);​​

    Click image for larger version

Name:	image.png
Views:	93
Size:	2.6 KB
ID:	1307061
    Click image for larger version

Name:	image.png
Views:	65
Size:	2.6 KB
ID:	1307062​​

    #2
    Hello sofortune,

    Set methods cannot be unset and will continue working with the previous price for new entries.
    Very importantly, if you are sing Set methods these need to be called with CalculationMode.Ticks before placing the entry order.

    Please review the information in the forum post linked below.


    Since the stop limit could fill sometime later, the set methods with CalculationMode.Price should not be called until the entry order has filled and the position is taken.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      sorry i am not 100% certain what the first line of your response means, but do you mean this could be addressed with using CalculationMode.Ticks instead of Price?

      I checked the link, it seems the other solution is to use a market order if price is beyond the limit?

      Comment


        #4
        Hello sofortune,

        The Set methods need to be reset before calling the entry method or they will have the set price of the previous entry which could be on the wrong side of the market.

        if (isPossibleShort && Close[0] > _indicatorCandleLowForShort)
        {
        // reset the stop loss before entry, so this is no longer set to a specific price which may be invalid when the entry fills
        SetStopLoss(CalculationMode.Ticks, 20)
        EnterShortStopLimit(NumberOfContracts, limitPrice, stopPrice, "ShortOrder");
        }

        // after the entry fills, the stop loss can be moved to any desired valid price using CalculationMode.Price
        if (Position.MarketPosition == Market Position.Short)
        {
        SetStopLoss("ShortOrder", CalculationMode.Price, Math.Max(GetCurrentAsk() + TickSize, _indicatorCandleHighForShort));
        }​
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        48 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        66 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 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