> I still do not understand what the difference between the size of an 
> array and the number of elements in an array is.

They are the same, but when you have a loop writing only 10 elements
to an array, that's not how many elements are in the array, it's only
the number of elements you've changed. The array might have 1000
elements and all you've done is overwrite the first 10.

The size of an array is how many elements it's physically possible to
change because there's actually memory allocated for their storage. In
AmiBroker that's always BarCount.

As I sort-of mentioned before, using arrays where the index is
something other than bars, and you fix the range of the index to
something other than BarCount, can easily lead to problems. If you
have such a formula in a backtest and run that across all symbols, the
moment you hit a symbol where BarCount is less than the maximum index
you use, you'll get an overflow error.

For example, if you have the following code in a backtest:

for (i = 0; i < 10; i++) myArr[i] = 0;

and run it over all symbols, if you hit a new listing that only has
five bars on the chart then you'll get an overflow error when myArr[5]
is referenced for that symbol.

Regards,
GP


Reply via email to