Array out of range

 

Hi guys, Why this code is out of range? it is in init() function

   for(int i=1; i<=iBars(NULL,PERIOD_M1)-1; i++)
     {
     Print(High[i]);
     }
 
Buba Akhrakhadze:

Hi guys, Why this code is out of range? it is in init() function

 for(int i=1; i<=iBars(NULL,PERIOD_M1)-1; i++)
     {
     Print(High[i]);
     }

You are getting the bar count from the M1 time-frame.

You are getting the high value from whatever the chart time-frame is.

You should not get any values like this in init as they may not be loaded yet.

 
Keith Watford:

You are getting the bar count from the M1 time-frame.

You are getting the high value from whatever the chart time-frame is.

You should not get any values like this in init as they may not be loaded yet.

Actually it shows result for 200 to 220 bars while there is more than 2000+ bars

 
Buba Akhrakhadze:

Actually it shows result for 200 to 220 bars while there is more than 2000+ bars

Also in OnCalculate() function there is result for 200-220 bars and after this it says array out of range, what is the problem?

 
Buba Akhrakhadze: what is the problem?
Keith already answered you.
Reason: