Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop order

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

    Stop order

    Good day, all

    I'm still trying understand why I received such error " An order has been ignored since the stop price ‘3979.75’ near the bar stamped ‘16.11.2022 18:48:06’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored." for ES instrument.

    Look at the log:

    ESOpenV3 is ONLINE 16.11.2022 18:30:30
    ESOpenV3 is ONLINE 16.11.2022 18:30:30
    Time[0].Date 16.11.2022 0:00:00
    Time[0] 16.11.2022 18:30:30
    HighO 3984,5
    LowO 3980,25
    RangeO 4,25
    TargetProfit 18,0625
    StopLong 3979,75
    StopShort 3985
    ESOpenV3
    Long !!
    CurrentBar 12147
    SignalBar 12147
    16.11.2022 18:30:44
    -----------------------------
    GetCurrentBid()3985,25
    GetCurrentAsk()3985,25
    StopLong3979,75
    ESOpenV3 [ES]
    [ES] Long 3985
    16.11.2022 18:30:44
    -----------------------------
    GetCurrentBid()3980,25
    GetCurrentAsk()3980,25
    StopLong3979,75
    ESOpenV3 [ES]
    [ES] Long 3985
    16.11.2022 18:48:06
    -----------------------------
    GetCurrentBid()3980,25
    GetCurrentAsk()3980,25
    StopLong3979,75
    Strategy 'ESOpenV3/-1': An order has been ignored since the stop price ‘3979.75’ near the bar stamped ‘16.11.2022 18:48:06’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.
    ESOpenV3 [ES]
    [ES] Long 3985
    16.11.2022 18:48:06​

    My code:
    Code:
     OnBarUpdate:
                           if (Position.MarketPosition == MarketPosition.Flat) {
    
                                if (PositionAccount.Quantity == 0) {
    
                                    SignalBar = 0;
    
                                    if (Signal_Long && count == 0) {
    
                                        EnterLong (0, ContractQty, "entry");
                                        SignalBar = CurrentBar;
                                        Print (this.Name);
                                        Print ("Long !!");
                                        Print ("CurrentBar " + CurrentBar);
                                        Print ("SignalBar " + SignalBar);
                                        Print (Time[0].ToString ());
                                        Print ("-----------------------------");
                                        BackBrush = Brushes.Green;
                                        BarBrush = Brushes.White;
                                        count += 1;
    
                                    }
                                    else if (Signal_Short && count == 0) {
                                        EnterShort (0, ContractQty, "entry");
                                        SignalBar = CurrentBar;
                                        Print (this.Name);
                                        Print ("Short !!");
                                        Print ("CurrentBar " + CurrentBar);
                                        Print ("SignalBar " + SignalBar);
                                        Print (Time[0].ToString ());
                                        Print ("-----------------------------");
                                        BackBrush = Brushes.Red;
                                        BarBrush = Brushes.White;
                                        count += 1;
                                    }
    
                                }
    
                            }​
    
    OnPositionUpdate:
    
                if (Position.MarketPosition == MarketPosition.Long) {
    
                    // +------------------------------------------------------------+
                    // | Set Long Target and Stop loss                              |
                    // +------------------------------------------------------------+
                    var target = Position.AveragePrice + TargetProfit;
    
                    Print("GetCurrentBid()" + GetCurrentBid());
                    Print("GetCurrentAsk()" + GetCurrentAsk());
                    Print("StopLong" + StopLong);
    
                    ExitLongStopMarket (0, true, 1, StopLong, "initialStop", "entry");
                    Print (this.Name + " [" + instrument + "]");
                    Print ("[" + instrument + "] Long " + Position.AveragePrice);
                    Print (Time[0].ToString ());
                    Print ("-----------------------------");
                    Dot stopDot = Draw.Dot (this, "initialStop" + CurrentBar, true, 0, StopLong, Brushes.WhiteSmoke);
    
                    // +------------------------------------------------------------+
                    // | Set TakeProfit                                 |
                    // +------------------------------------------------------------+
                    ExitLongLimit (0, true, 1, target, "exit", "entry");
                    Square targetSquare = Draw.Square (this, "initialTarget" + CurrentBar, true, 0, target, Brushes.White);
    
                }
    
                if (Position.MarketPosition == MarketPosition.Short) {
    
                    // +------------------------------------------------------------+
                    // | Set Short Target and Stop loss                             |
                    // +------------------------------------------------------------+
                    var target = Position.AveragePrice - TargetProfit;
    
                    ExitShortStopMarket (0, true, 1, StopShort, "initialStop", "entry");
                    Print (this.Name + " [" + instrument + "]");
                    Print ("[" + instrument + "] Short " + Position.AveragePrice);
                    Print (Time[0].ToString ());
                    Print ("-----------------------------");
                    Dot stopDot = Draw.Dot (this, "initialStop" + CurrentBar, true, 0, StopShort, Brushes.WhiteSmoke);
    
                    // +------------------------------------------------------------+
                    // | Set TakeProfit                                    |
                    // +------------------------------------------------------------+
                    ExitShortLimit (0, true, 1, target, "exit", "entry");
                    Square targetSquare = Draw.Square (this, "initialTarget" + CurrentBar, true, 0, target, Brushes.White);
    
                }
    
            }​

    #2
    Hi, thanks for posting. The backtest sometimes needs intrabar grainularity for more accurate order fill estimation. Here is more reading on adding intrabar granularity, something you will need to do often if you are backtesting strategies:
    Hello, I`ve created a strategy to trade the breakout of certain ranges. In the backtest, I found an ignored short trade. (Output Window: Strategy 'BOR1/-1': An order has been ignored since the stop price ‘1.11507’ near the bar stamped ‘08.01.2020 05:30:00’ is invalid based on the price range of the


    Here is a troubleshooting guide on the "Order Out Of Range" error you got here:
    I am coding a strategy and am receiving numerous instances of the following error message: A Buy order placed at '[time]' has been ignored since the stop price is less than or equal to the close price of the current bar. I have searched the NinjaTrader forums and have read many posts related to this error message, but none


    Kind regards,
    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    68 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    41 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    24 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    27 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    54 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X