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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      548 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X