Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on calling the OnBarUpate

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

    Error on calling the OnBarUpate

    Hello

    I m trying to run simple code

    if (High[0] > High[1] && High[1] > High[2])
    Print("Two successive higher highs");
    DrawArrowDown("My down arrow" + CurrentBar, true, 0, High[0] + TickSize, Color.Blue);

    I m getting "Error on calling the onBarupdate method for indicator Myindi on bar U:index was out of range.Must be non-negative and less than the size of the collection Parameter name:index"
    it happen whenever i compare current bar with previous bar [1].its work fine if i compare current bar like Open[0] > Close [0]

    Do i need to initialize something to run this code?

    Thanks
    mwave

    #2
    mwave, you try accessing bars at the start of the chart that are present in the dataseries you're referring to (for example there's no High[1] defined at the first bar of the chart). You can add this check to the start of your OnBarUpdate -

    Code:
     
    if (CurrentBar < 2) return;

    Comment


      #3
      Thanks Bertrand, Its work!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      596 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      343 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      556 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      554 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X