Sure when I should have created MyArray with MyArray=Close etc. there are a lot 
of elements in MyArray. And when I should overwrite 10 elements with MyForLoop, 
I would have had an array with many more elements than mentioned 10. But that's 
not the case. I am not using an array created within the AB environment. 
MyArray has been created from scratch. Just by adding 10 elements to MyArray. 
Therefore I just don not understand why I should have more than 10 elements in 
MyArray. And when I am testing if I have more elements, the error message says 
that there are no more elements than 10. As you see, I am still confused with 
what you are telling me ...

Also see my answer to Fred ...

Regards, Ton.

----- Original Message ----- 
  From: gp_sydney 
  To: [email protected] 
  Sent: Saturday, June 16, 2007 2:08 AM
  Subject: [amibroker] Re: New file uploaded to amibroker


  > 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