Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cannot access bar number 2 or greater

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

    Cannot access bar number 2 or greater

    Hello,

    I'm trying to plot by specifying the bar number (e.g. High[BarNumber], Low[BarNumber]) but I can only plot lines for High[0], Low[0] or High[1] or Low[1], but not High[2], Low[2] or High[3], Low[3], etc.

    I got error message:
    Indicator 'RichardBarNumberTest': Error on calling 'OnBarUpdate' method on bar 1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    This looks like a simple problem to fix, but I have tried many ways still not able to fix. Would appreciate it very much if someone can help me fix this problem.

    Thank you.

    Richard​
    Attached Files

    #2
    Hello Richard,

    Are you waiting until there are at least 3 bars before using an index of [2] bars ago?

    Below is a link to a forum post on index errors.
    Hello, I want to create an indicator that show data in a chart but calculate in other charttime different to the time of the chart where is showed. For example:
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea_B,

      Fantastic, your suggestion solved my problem. Much appreciated!

      Richard

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      43 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      14 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      20 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      22 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X