Why can't write to dynamic array ? (Array out of range in 'TestDynFile.mq5' (64,7))

 

Does anybody know why I can't writa to dynamic array?

There is run time error  "Array out of range in 'TestDynFile.mq5' (64,7)".

When I declare it as static, it is OK.  File si attached.

Thanks for any answer(s).

Bohem

Documentation on MQL5: MQL5 programs / Runtime Errors
  • www.mql5.com
MQL5 programs / Runtime Errors - Documentation on MQL5
Files:
 

A dynamic array must be resized before using/

datetime       BarTim[];

//--- Emanem definovanй promмnnй
bool Is2or4digits=true;   //false for ALPARI, true for FxCast
double VyskaBaru,Bo,Bh,Bl,Bc;              //Konstantnн vэљka barщ jako Value hodnta
double BorderDif;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {//--- indicator buffers mapping
   SetIndexBuffer(0,BarOp,INDICATOR_DATA);
   SetIndexBuffer(1,BarHi,INDICATOR_DATA);
   SetIndexBuffer(2,BarLo,INDICATOR_DATA);
   SetIndexBuffer(3,BarCl,INDICATOR_DATA);
   SetIndexBuffer(4,FastEMABuffer,INDICATOR_DATA);
   SetIndexBuffer(5,SlowEMABuffer,INDICATOR_DATA);
   
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);

//---
      ArrayResize(BarTim,1);
      BarTim[1]= TimeLocal();
   

   return(0);
  }

 
Rosh:

A dynamic array must be resized before using/


Thanks Rosh for answer, I mast study mach more !!!

Bohem

Reason: