Why am I getting "Array out of range" error?
Thanks :) but even with this in here, I am still getting Array out of range for the "SwingValue[i]=iCustom(Symbol(),_Period,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,i);" line 9which is where the error was initially as well.
I've tried it at multiple locations, this one seems to make the most sense. sBars or Bars does not seem to matter.
int sBars; sBars=Bars; double SwingValue[]; //---Moved below int sBar ArrayResize(SwingValue,sBars); //--------Added Line for( int i = sBars; i>=0; i--) //starts at first bar, to current bar { SwingValue[i]=iCustom(Symbol(),_Period,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,i); if(SwingValue[i] !=0) { Print(SwingValue[i]); } }
[EDIT]
Ive changed the
for( int i = sBars; i>=0; i--)
to
for( int i = sBars-1; i>=0; i--)
which makes sense I guess.
Thanks :)
for( int i = sBars; i>=0; i--)
should be
for( int i = sBars-1; i>=0; i--)
Thanks for any insights. :)