Array out of range

 

Hi

I have an custom EMA that calculate daily HLC/3 as its applied price

I get the error "array out of range when it's initializing, then the error disappears when I change the time frame


Thank you!



   datetime time1[];
 
   ArrayCopySeries(time1,MODE_TIME,NULL,PERIOD_D1);
  
   for(i=0,y=0;i<limit;i++)
    {
      if(Time[i]<time1[y])       //time1[y] is out of range
        y++;              

      HLC3[i]=iMA(NULL,PERIOD_D1,1,0,MODE_EMA,PRICE_TYPICAL,y);
    }   
   
//---Calculation
   for(i=limit-2;i>=0;i--)  
     EMA_Value[i] = ExponentialMA(i,EMA_Value_Period,EMA_Value[i+1],HLC3);

 

On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4 2019.05.20

Reason: