Does AFL array start with index 0 or 1?

I know this is a basic question but I want to be sure. Does AFL array start with index 0 or 1?

From this page, I get the impression that the first bar index in the array is 1.
https://www.amibroker.com/guide/h_understandafl.html

However, BarIndex() returns an array of zero-based bar number.
https://www.amibroker.com/guide/afl/barindex.html

So, I am not sure whether an AFL array start with index 0 or 1.

Yes, indexing starts at zero (that's the case for all 1-dim and multi-dim arrays). In the table of 1st AB help link you posted you see bar numbers not indexes. So don't mix bar index with bar number.

Here for further clarification two additional pictures showing 1-dim and multi-dim array examples.

1-dim
12

2-dim
WqOt9xZ

5 Likes

This https://www.amibroker.com/guide/h_understandafl.html uses "Excel" analogy to number the columns. Since Excel starts column numbering with 1, this article uses the same. But then everything in AmiBroker is zero-based. And I guess that I need to change this article as it may confuse beginners.

2 Likes