Array out of range error

Back to topics list To post a new topic, please log in or register
avatar
12
insub 2015.06.21 13:31
 
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;
avatar
Moderator
3206
angevoyageur 2015.06.21 14:36 #
 
You have to use static arrays, or to resize dynamic arrays.
avatar
12
insub 2015.06.21 18:05 #
 
Big thanks. It works now properly.
Back to topics list  

To add comments, please log in or register