mql4 array size limitation - page 2

 
Ickyrus:

The stupid solution is to use a one dimensional array and as many variables as needed to represent the dimensions - which is in effect what is happening anyway.

access any cell by multiplying the dimension variables together. Only problem is you cant have an array start with zero, but that is just a number shift.

-

Mind you if my memory is correct the intel 286 and onwards have flaws in accessing memory at the instruction set level and thesse flaws were kept in the future chips so as to remain backward compatable.


Yes, that's what i wound up doing, i condensed frour dimensions into two by using a combination of multiplication and addition, and left the other dimension alone. Note that you cannot use straight up multiplication because you run into the following issue for the first two condensed dimensions in the range [1..3]:

1 2 3
1 1 2 3
2 2 4 6
3 3 6 9

if you had array[a][b][c][d], you can't simply make it array[a*b][c*d], because when a=3,b=1, the first index of the condensed array is the same as when a=1,b=3. That would have been a totaly different element in the original array.

The correct approach would be array [a+b*3][c+d*3], thus:

\ 1 2 3
1 4 7 10
2 5 8 11
3 6 9 12

This addresses the data integrity and uniqueness, but you now have additional computational overhead due to the multiplication and addition required just to address an array element. This can compound to a significant computational hit when you have very long for loops (like when you run millions of histories). It would certainly be faster if you just had additional array dimensions in the first place to work with.

Reason: