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 cmoran13, 04-16-2026, 01:02 PM
      0 responses
      43 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      25 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      162 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      98 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      158 views
      2 likes
      Last Post CaptainJack  
      Working...
      X