Multidimensional on the Second Dimension

 
Hi

I see that mql4 has ArraySort and ArrayBSearch but all these only work on the first dimension.

Here is an example array and what I want to accomplish

array[0][0] = 100;
array[0][1] = 1;

array[1][0] = 400;
array[1][1] = 2;

array[2][0] = 200;
array[3][1] = 3;

I want to get the highest value 400 and print it out like this:
" 400 on 2 "

Another question: Do I have to specify the size of an array like this everytime "int array[50];" , I might not know the size.

Happy hOlidays
 
bonechair:

Another question: Do I have to specify the size of an array like this everytime "int array[50];" , I might not know the size.


See ArrayResize
 

"Do I have to specify the size of an array like this everytime "int array[50];" , I might not know the size."

To allocate memory for the array, you have to give it a size either in the declaration. ..

double myArray[100];

or before using it...

double myArray[]; // no size declared

...

ArrayResize(myArray, 100);

or

int sizeNeeded = someCalculation;

ArrayResize(myArray, sizeNeeded);

If you don't allocate memory for the array, it might work, it might work oddly, it might crash the program.

 
Hi thanks Guys, any ideas on my first question?
Is it possible todo that in mql4?
 
So I'm guessing this not possible? First Question???
 
You can read size of second dimension but can not set it. See ArrayRange().
 

I have some problem..

how to print out two array ?? (like the first case)


array[0][0] = 100;
array[0][1] = 1;

array[1][0] = 400;
array[1][1] = 2;

array[2][0] = 200;
array[3][1] = 3;


how to print out high value "400,2" ??

 

Hello ??? its imposible ??

 
disyon wrote >>

Hello ??? its imposible ??

You can make function with simle loop:

max = 0; // or ..

for (i=0; i<sizeofarray; i++) {

if (array[i][0] > max) {

max = array[i][0];

indmax = i;

}

}

Print(array[indmax][0], array[indmax][1]);

Reason: