Quantcast
Channel: Traderji.com
Viewing all articles
Browse latest Browse all 10287

Help debugging simple AFL code

$
0
0
Hi,

Please help me debug following code.

Quote:


SetBarsRequired( sbrAll, sbrAll );
printf("BarCount is %f\n", BarCount);
printf("Close[Barcount-1] is %f\n", Close[BarCount-1]);
printf("Close[0] is %f\n", Close[0]);
printf("Close[20] is %f\n", Close[20]);
printf("Close[200] is %f\n", Close[200]);

I am encountering error in 6th line when accessing the array Close beyond a certain index. The error encountered is following:
Error 10. Array subscript out of range. You must not access array elements outside 0..(BarCount-1) range. You attempted to access non-existing 200-th element of array.

I have run this on two symbol databases (NIFTY, NiftyEOD). Both give the same error (but for different index range).
Database NIFTY ---- cannot access indices 21 and beyond
Database NiftyEOD --- cannot access indices 200 and beyond.

I have turned off quickAFL in first line. I printed value of BarCount in 2nd line to be sure that I am not trying to access non-existing index. What is bizzare is that I am able to access these same indices by putting suitable value of x in the notation Close[BarCount-x], but not by directly writing the index value. For example, for database NiftyEOD, BarCount is 373. So I cannot directly access Close[200] but can access it by writing Close[BarCount-173].

Same error is encountered when accessing other array like Open, High etc. Other lines in code give correct output when I remove the 6th line.

Following are the links to database files I am using so that you can reproduce the error.
NIFTY: https://docs.google.com/file/d/0B86a...it?usp=sharing
NiftyEOD: https://docs.google.com/file/d/0B86a...it?usp=sharing

P.S. This is my first attempt writing code for Amibroker, so pardon me if I have made some obvious mistakes. :)

Viewing all articles
Browse latest Browse all 10287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>