mql4 array size limitation

 

I'm trying to initialize a global array

double set[2][8][2][8][100000];

but I get the following compiling error:

'100000' - too large dimension

What gives? I thought i read somewhere that mql4 allows for up to eight dimensions in arrays.

 

25,600,000 multiplied by the number of bytes needed to represent a double. do you have that much memory?

 

https://docs.mql4.com/array

Arrays are allowed to be maximum four-dimensional
 
Ickyrus:

25,600,000 multiplied by the number of bytes needed to represent a double. do you have that much memory?


There are 8 Bytes in a double, so that's 204.8MB. No sweat. Most machines nowadays have many gigs of RAM.
 

CRAP! I'm going to have to think about how to get around that...

I guess i got the indicator buffer limitation confused with the array dimension limitation. Thanks, Phillip.

 

double set[2][8][2][8][100000];

You probably already knew this, the left-most first dimension is the resizable one. Also just found out on mql5 that the first dimension when used on function can not be initialized with size. See mql5 recent list of changes.

 
cameofx:

You probably already knew this, the left-most first dimension is the resizable one. Also just found out on mql5 that the first dimension when used on function can not be initialized with size. See mql5 recent list of changes.


Thanks for that. I was thinking I'll modify my arrays structures to make use of the re-sizable first dimension, since I have to restructure everything anyhow.

I can get around the second issue by using global arrays (just have to be careful).

 
cameofx:

You probably already knew this, the left-most first dimension is the resizable one. Also just found out on mql5 that the first dimension when used on function can not be initialized with size. See mql5 recent list of changes.


I assume you are referring to this:
MQL5: It is now forbidden to specify a static array (an array with a defined first dimension) as a function parameter.

What is the problem with it? Call your function without explicitly declaring the first-dimension size as a parameter but then immediately size it within the call function. I don't see how this poses a problem. What am I missing?
 

I assume you are referring to this [...] I don't see how this poses a problem. What am I missing?

That is correct. I'm afraid I don't know the answer Phil, I can't see the wisdom behind the change also... I'm just lurking about the mql5 & found that to be rather interesting :).

 

If I were to make guess I'd assume the decision came down to making something about the compiler more robust and/or easier to debug in the future. (not your code, but their code which they use to create the compilers which we intend to use)

 

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.

Reason: