After declaration, You need to resize array to Bars amount of items.
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--)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thanks for any insights. :)