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 sjsj2732, 03-23-2026, 04:31 AM
      0 responses
      69 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      312 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      305 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      146 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      105 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X