Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Index was outside the bounds of the array" error

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

    "Index was outside the bounds of the array" error

    Hi,

    I was doing some tests with PriorDayOHLC indicator on a strategy and everything was going well.

    I had to restart NT and sudendly I receive an "Index was outside the bounds of the array" error

    The code that generates the error is :
    PreviousLow = PriorDayOHLC().PriorLow[0];

    THe strategy is executed from a strategy with 3 days of data. I think this is not the problem. I restarted again NT and the problem persists

    #2
    guillembm,

    Please add the following line to your code.

    If ( CurrentBar < 1)
    {
    return;
    }

    The data series are built from the beginning of your chart, so at some point they have no elements in them, which is what is probably throwing this exception.
    Adam P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    84 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    47 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    66 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    69 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    58 views
    0 likes
    Last Post CarlTrading  
    Working...
    X