AmiBroker is fine and data are fine too. Data have nothing to do with that (i.e. the fact that you see it sometimes is just pure chance).
Your code is incorrect. Your x[0]
and y[0]
are UNINITALIZED (because your for
loop starts from 1 instead of 0) ! Hence you are getting random value for first element. Uninitialized array elements get RANDOM value (actually the value that was in RAM in that particular cell before - since it is likely to be used for something else completely unrelated - you are getting weird values).
for (i = 1; i < 3; i++) // array indices start from ZERO, but you are starting from 1
{
x[ i ] = ..; // x[ 0 ] will never get assigned !
You only assign x[1]
, x[2]
, and so on.. You forgot to assign value to x[0]
. You can do this either by doing
x[ 0 ] = 0; // anywhere
or by doing
x = 0; // before the loop
The second thing works because of type coercion When scalar becomes an array, aka. type coercion in AFL so scalar 0 becomes array filled with zeros, once you start treating it as array (using indices).