PureBytes Links
Trading Reference Links
|
You can't do loops over arrays to arbitrary index values (in this case
63 and 127) unless you are sure that you will never run the code over
a stock that has less than that many bars. Array indices reference
bars, and every stock will likely have a different number of bars. If
you run this over a portfolio of stocks, the moment you hit a stock
with less than 64 bars you'll get that error on the first loop.
Normally you should use BarCount, or some smaller value, as the loop
limit. If you want to use a fixed value unrelated to BarCount, then
you need to add a test for your value exceeding BarCount before you
enter the loop, and skip the whole loop for stocks with insufficient
bars. Loops are usually to iterate over all bars though, so using
BarCount in the loop termination condition makes sense.
Note that valid indices are from zero to BarCount-1, so you need to
use strictly less than BarCount (ie. "< BarCount").
Regards,
GP
--- In amibroker@xxxxxxxxxxxxxxx, Humblybob <humblybob1@xxx> wrote:
>
> Would be highly obliged if someone can help me with correcting
this error
> in an afl. I am not a programmer and hence struggle with this. I do
realize
> that this error has to do with the number of bars. What values do I
need to
> change so that this afl works with even those scrips that have even
1 or no
> bars.
>
> limitvalue=63
> startValue = 64;
>
> //----
>
> for (i = 0; i <= limitValue; i++) list [i] = -1000000;
>
> for (i = startValue; i <= 127; i++) list [i]
> ------------------------------------------------^
>
> Error 10.
> Subscript out of range.
> You must not access array elements outside 0..(BarCount-1) range
>
>
> Many thanks in advance.
>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|