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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      177 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      332 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      254 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      356 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      184 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X