Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy orders errors

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

    Strategy orders errors

    This is my Entry condition:

    Code:
    // Long Entry
    
    double currentAsk = GetCurrentAsk();
    
    if (Close[0] > ema[0] && rsi[0] ..................... rest of my condition)
    
    {
    
        double stopPrice = currentAsk;
    
        if (stopPrice > GetCurrentBid())
    
        {
    
            EnterLongStopMarket(5, stopPrice, "Long");
    
        }
    
    }
    ​
    I keep getting this erros:

    Buy stop or buy stop limit orders can't be placed below the market. affected Order: BuyToCover 5

    other errors in screenshots bellow:

    How can I fix this please?

    #2
    Hello onlinebusiness,

    Buy orders fill at the ask, sell orders fill at the bid.
    '
    For a buy stop order, ensure the stop price is greater than the ask, not the bid.

    For a sell stop order, ensure the stop price is less than the bid.

    if (stopPrice > GetCurrentAsk())
    EnterLongStopMarket(5, stopPrice, "Long");
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,
      Thanks for the reply

      I used your edit but I still got the same error. check screenshot:

      Comment


        #4
        Hello onlinebusiness,

        I wouldn't expect that this condition would evaluate as true.

        You are assigning the stopPrice to the current ask and then condition checks to see if the stopPrice is greater than the current ask.

        Are you expecting that the current ask will have fallen in the fraction of a fraction of a second it takes to evaluate the next to lines of code?

        Are you 100% this is the code causing the error?

        That said, have you compiled and reloaded the script after making any changes?

        Enable TraceOrders and ddd prints to confirm this is the line causing the error.


        Within the if statement action block, print the time of the bar, print stopPrice and print GetCurrentAsk().
        Then in OnOrderUpdate() print the order object (outside of any conditions).

        Include the output text file with your reply.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        96 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        154 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        82 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        54 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        71 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X