Download MetaTrader 5

Array out of range error

To add comments, please log in or register
Tom
34
Tom  
long volume[];
double candlesize[];

for(int z=5; z>=0; z--)
{  
   volume[z] = iVolume(Symbol(), Period(), z);
   
   if(Close[z]>Open[z])
   candlesize[z] = ((Close[z]-Open[z])*100000);
   
   if(Close[z]<Open[z])
   candlesize[z] = ((Open[z]-Close[z])*100000);
}

Wrote this to caclutate out the candlesize in pips. Getting the Array out of range error. If i remove "#property strict" it works.

Also tried a loop limit function but getting error "void function returns a value".

 
int limit;

int counted_bars=IndicatorCounted();

if(counted_bars<0) 
return(-1);

if(counted_bars>0) 
counted_bars--;

limit=Bars-counted_bars;
Alain Verleyen
Moderator
31475
Alain Verleyen  
You have to use static arrays, or to resize dynamic arrays.
Tom
34
Tom  
Big thanks. It works now properly.
To add comments, please log in or register