Any idea how to get an arrays variable previous value ? For instance, I tried this silly code:
$x[0] = close
return $x[0][1]
but $x[0][1] which is supposed to be the old value returns the present value same as $x[0]
It’s not allowed because arrays are not historicized, unlike common variables which allow to see previously retained values.
IF you have an array and want to historicize a very few elements, say elements 1 and 4, you can write:
$Element[0] = close //$Element[0][1] is not allowed
$Element[1] = high //$Element[1][1] is not allowed
$Element[2] = close //$Element[2][1] is not allowed
$Element[3] = low //$Element[3][1] is not allowed
$Element[4] = range //$Element[4][1] is not allowed
a = $Element[1] //a[1], a[2], ... is allowed to see the history of Element[1]
b = $Element[4] //b[1], b[2], ... is allowed to see the history of Element[4]
(unless you want to use a1, a2, a3,… a1000, provided you have enough time and memory).
ok, maybe they reserve the format $x[i][j] for future 2-D arrays. Yes, I found a simple workaround by using temp variables like you said, but it takes memory and time for long vectors:
$x[0] = open
$x[1] = close
...
a = $x[0]
b = $x[1]
...
return a[1], b[1],...
Historizing arrays would have take more memory than this workaround, considering that the current one dimension array can handle one million column! 🙂