User error, FYI: BarCount can be less than 1000, was: for statement


I have used

SetBarsRequired(-2, -2`);

to switch off quick AFL as some of the loops need to run for all data.

For other loops they do not need to run for all data and thats why I am using

for(i = BarCount-1000 ; i< BarCount; i++)

but this is giving error
array subscript out of range, if I do BarCount-100, then its working.

I changed number of bars for debug to 3000 but still its not working.

thanks to help

Recommended reading:

The question you should ask yourself first.. Do you actually require looping at all? But at least you should place all code not being required within loop outside of it.

YES I do need loop as i am creating custom time framing with different intervals for first and last bar. This program is for live market not for backtesting, that means with every tick program will be rerun. So in order to make program fast and not run loop every time from i=0, I am storing loop results in static variable on first run. and every next time, I do not want loop to start from I=0 but i=barcount-1000 and and update last few values of static variable.

Did you even bother to read the link @fxshrat has given you? FYI: BarCount can be less than 1000 and then your BarCount - 1000 yields NEGATIVE number (negative indexes to array which are obviously wrong).

yes I read it, my reply was just to explain why this is required. I understood that this is not supported in Amibroker. All my loops need to from 0 to 200 (max). There is no way to start loop from Barcount-1000.

If you don't understand, you should not say not supported.

Also 1000 is an arbitrary number which makes it meaningless.
instead you can deal with negative bar index to get around out of range error.

i = Max( BarCount-1000, 0); 

and in Analysis settings, you can control QuickAFL using checkbox as well and read how that works too.

Agree, my apologies for using " not supported"

Yes, it works


This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.