How to find the size of an array

In c++ you can find the number of elements in a container by using the sizeof(). I want to know is there any alternative to sizeof in AFL , if not, how can i find the size of an array in afl?

It is BarCount - built-in variable holding number of bars == number of elements in the array

1 Like

in regards with your answer i have a little doubt with something I'm working
dt = DateTime();
array = Zig(P,change);
for ( i = 0; i < BarCount; i++ )
// write ticker name
fputs( Name() + "," , fh );

    // write date/time information
    fputs( DateTimeToStr( dt[ i ] ) + ",", fh );

    //write quotations and go to the next line
    qs = StrFormat( "%g\n",array[i] );
    fputs( qs, fh );`


here whose BarCount will be used 'array' or 'dt'

All the arrays for a single ticker/instrument are the same size (== BarCount).

From the above-linked document titled: **Understanding how AFL works (one absolute must read):

Amibroker has stored in its database 6 arrays for each symbol.
One for opening price, one for the low price, one for the high price, one for the closing price and one for volume These can be referenced in AFL as open, low, high, close, volume, openint or o, l, h, c, v, oi.

Any other array is calculated from these 6 arrays using formulae built into AFL. These arrays are not stored in the database but calculated where necessary.

1 Like

how can i calculate the size of those arrays.

No need: their size is BarCount (for all of them) since in AmiBroker all the arrays created/returned by its built-in functions are based on the six main arrays (whose size correspond to the number of bars stored in the database for each symbol).

Please, read the above link and study it well until you completely understand how it works.

@tarscase, in addition to the above document, a lot of other useful resources to learn more about Programming in AmiBroker Formula Language (AFL) are listed in this thread How do I learn AFL?

In particular, I suggest you to do extensive use of the explorations to see what values are actually stored in the arrays.

5 posts were split to a new topic: Accessing quotation database via OLE