Download MetaTrader 5

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

To add comments, please log in or register
Bohem
17
Bohem 2011.01.10 11:52 

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:
Rashid Umarov
Admin
11989
Rashid Umarov 2011.01.10 13:42  

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);
  }

Bohem
17
Bohem 2011.01.10 13:52  
Rosh:

A dynamic array must be resized before using/


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

Bohem

To add comments, please log in or register