How long size we can give to an array? - page 2

 
So does anyone know if there actually is a maximum size for double arrays? I have a multidimensional array [500][2401][4] and i have a nagging suspicion that the values at the higher indexes are not being filled properly due to some strange behavior in my ea. Yes, i know this is a total of 4.8 million elements, and given that a double takes 8 bytes on a 32 bit compiler that's a 36.6 MB array. This should not be a problem given that my machine has 16 GB of RAM, but it could be a big problem if the compiler is not doing what i think it should be doing. So is anyone aware of any mql4 limitations that limit the maximum number of elements in an array?
 
Come to think of it, perhaps a multidimensional array is a pretty lousy way to do what I'm trying to do here. Is there a way to define a struct, class, linked list or array of objects of any kind in mql4? I'm trying to store different properties for each bar on a chart.
 
gatornuke:
Come to think of it, perhaps a multidimensional array is a pretty lousy way to do what I'm trying to do here. Is there a way to define a struct, class, linked list or array of objects of any kind in mql4? I'm trying to store different properties for each bar on a chart.
Use an array . . . one value for each bar, then use bit masking to set and retrieve information about the bar from the single value for the bar in the array. This works if your properties are binary, on or off, if you need variable type properties this won't work.
 
I have four different properties with7 possible values each. Bit masking won't work since my properties are not binary. I guess i can use 4 separate integer arrays and keep their indexes synchronized, then use for loops to lookup values. I can see all the overhead this is going to cause. My code will ruin like molasses.
 
gatornuke:
I have four different properties with7 possible values each. Bit masking won't work since my properties are not binary. I guess i can use 4 separate integer arrays and keep their indexes synchronized, then use for loops to lookup values. I can see all the overhead this is going to cause. My code will ruin like molasses.
So you have 28 properties ( 4 x 7 ) . . . so bit masking with an array of integers will work, and it will be very, very fast.
 
You're right, raptor. An integer array would have 32 bits to play with. This can store my 28 properties plus 4 more. Thanks for pointing me in this direction. Looks like i have some homework tonight.
 
gatornuke: that's a 36.6 MB array. This should not be a problem given that my machine has 16 GB of RAM,
Ram on your machine is irrelevant. Mt4 is a 32 bit program, the most it will use is 2GB.
 
I've got to be honest, i've never done any bitmasking. I understand how it works and what i need to do, but have no clue what syntax to use in mql4. A couple of simple examples would be great. Anywhere you can point?
 
gatornuke:
I've got to be honest, i've never done any bitmasking. I understand how it works and what i need to do, but have no clue what syntax to use in mql4. A couple of simple examples would be great. Anywhere you can point?

It's very simple . . . if your array is BarParameters[] and you have the following parameter set:

#define PARAMETER1  1
#define PARAMETER2  2
#define PARAMETER3  4
#define PARAMETER4  8
#define PARAMETER5  16

to set parameters 1 and 4 for bar number 10 you would do this . . .

BarParameters[10] |= PARAMETER1;
BarParameters[10] |= PARAMETER4;


To read if a parameter is set you would do this . . .

if(BarParameters[10] & PARAMETER3 == PARAMETER3)
   Print("Bar 10 has Parameter 3 set ! ! ");

You can find the bitwise operators here and some assignment operators

If you need more info just ask.

 
You can also encapsulate the operations
void SetBitMap(int& array, int iArray, int bm){         array[iArray] |= bm; }
int  GetBitMap(int  array, int iArray, int bm){ return( array[iArray] & bm); }

if(GetBitMap(BarParameters,10,PARAMETER3)) Print("Bar 10 has Parameter 3 set ! ! ");
Reason: