Need help for function "ArrayCompare"

 

Hello,

am not sure whether I understood the function ArrayCompare right or not. From my understanding I thought I could compare the content of 2 Array.

I tried the following code:

extern int MaxWorkingOrders = 1;

// Global variable

int array_buyTicket[];

int array_sellTicket[];

int array_toCompare[];

// During inititalization:

ArrayResize(array_buyTicket,MaxWorkingOrders);

ArrayResize(array_buyTicket,MaxWorkingOrders);

ArrayResize(array_toCompare,MaxWorkingOrders);

ArrayInitialize(array_toCompare, 0);

// Somewhere in the code:

// force an error

array_buyTicket[0] = 397;

Print("array_buyTicket_",0," = ",array_buyTicket[0]);

// force an error end

int Array_BuyTicketIsEmpty = ArrayCompare(array_buyTicket,array_toCompare,0,0,WHOLE_ARRAY);

Print("Array_BuyTicketIsEmpty: ",Array_BuyTicketIsEmpty);

int Array_SellTicketIsEmpty = ArrayCompare(array_sellTicket,array_toCompare,0,0,WHOLE_ARRAY);

Print("Array_SellTicketIsEmpty: ",Array_SellTicketIsEmpty);

The result which I get during execution is:

11:08:57 2010.01.18 11:00 Forex_ORB-v1.10.1 GBPJPY,M5: array_buyTicket_0 = 0

11:08:57 2010.01.18 11:00 Forex_ORB-v1.10.1 GBPJPY,M5: array_sellTicket_0 = 0

11:08:57 2010.01.18 11:00 Forex_ORB-v1.10.1 GBPJPY,M5: array_buyTicket_0 = 397

11:08:57 2010.01.18 11:00 Forex_ORB-v1.10.1 GBPJPY,M5: Array_BuyTicketIsEmpty: 0

11:08:57 2010.01.18 11:00 Forex_ORB-v1.10.1 GBPJPY,M5: Array_SellTicketIsEmpty: 0

So my question now: Why do I get the value Array_BuyTicketIsEmpty: 0 even the arrays are not equal. Does the function ArrayCompare only compare the size of the array but not the content of the array?

Thanks in advance!

 

ArrayCompare

Returned value

·-1, if array1[] less than array2[]

·0, if array1[] equal to array2[]

·1, if array1[] more than array2[]

·-2, if an error occurs due to incompatibility of the types of compared arrays or if start1, start2 or count values lead to falling outside the array.

 
qjol:

ArrayCompare

Returned value

·-1, if array1[] less than array2[]

·0, if array1[] equal to array2[]

·1, if array1[] more than array2[]

·-2, if an error occurs due to incompatibility of the types of compared arrays or if start1, start2 or count values lead to falling outside the array.

As u can see from my code i loade the array_buyTicket with a value of 397, array_toCompare has still the value 0. So the array content is not equal. Does ArrayCompare only compare the size and not the content?
 
Lines_ss:

Hello,

am not sure whether I understood the function ArrayCompare right or not. From my understanding I thought I could compare the content of 2 Array.

...

Thanks in advance!

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

 
Lines_ss:


Does ArrayCompare only compare the size and not the content?


that's right
 
angevoyageur:
Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

Sorry, next time I will remember. It's my first time I used the forum.
 
Lines_ss:
Sorry, next time I will remember. It's my first time I used the forum.
Don't worry, this is why I explain that to you.
 
qjol:

that's right
@qjol: U are my hero ;-) Mql documentation was quite miss understanding for me.But now I understand the problems in my EA.
 
If you want to compare arrays what they contain, use a for loop
 
qjol:
If you want to compare arrays what they contain, use a for loop
Thanks for ur help, that's the way I will now implement the compare function.
Reason: