Limitations of the IEEE floating point standard and BarIndex(), iterator for loop

Dear Colleagues,

I understand the limitations of the IEEE floating point standard. But due to these limitations it is impossible to work with arrays in the database, in which, for example, more than 2 million bar:

BarIndex() is incorrect

iterator for loop will overflow:
for( i = 0; i < BarCount; i++ )

For testing on stories, I use a database with a 10-year history with 1-minute bars (I do not think that this amount of data is excessive for back-testing). I understand that this database can be divided into several small ones, but this is inconvenient.

How do you solve this problem?

FYI, there is endless loop detection threshold setting (default value at 100k).


1 Like

thank you for your reply. I know about this options and use it.

I mean, for amount of bars more then 10 millions, I get error "Array subscript out or range" with this code, e.g.:

_trace("Test "+C[i]);

Integers represented as Single-precision (32 bit Floats) still retain an accurate range of +/- 16 million without any rounding errors.


Please RE-read this and really dig into details. 32-bit IEEE has 23 bit mantisa, 8 bit exponent and 1 bit sign. Mantisa length decides about precision. Use the calculator that article points to and try to enter 19 999 999 and you will see it rounded to 20 000 000

The solution is simple: use QUICK AFL:

It is the only sensible way because looping over 20 million elements in the array is total overkill and QuickAFL allows you to have lots of data in the database BUT process only VISIBLE ones (not everything).


@Tomasz, @travick ,

thank you for your reply

Next time you should formulate better initial post.
You said more than 2 million bars there.

2000001 is more than 2 million and is 8 million(!) below of 10 million and 18 million (!) below of 20 million.


How is Barindex incorrect at 2000001?


not to mention no array subscript out of range error.

are between 3 to 4 million bars but not 10 million.

1 Like

Ccompletely agree, this is my mistake.