How to compare 2 strings?

 

Hi guys,

I have following code:

if (trend == "BUY") {
...
}

I have also tried StringCompare(trend, "BUY") == 0.

Neither work.

Can you please advise how to compare strings in mql?

Cheers,

Ash.

 
Ashish Kulkarni:

Hi guys,

I have following code:

I have also tried StringCompare(trend, "BUY") == 0.

Neither work.

Can you please advise how to compare strings in mql?

Cheers,

Ash.

Like you did, provided than 'trend' is a string variable that could be equal to "BUY".

 
if (StringCompare(trend, "BUY") == 0) {
...
}
works fine for me. I think there is a bug somewhere different in your code.
 
Use the debugger or print out your variables, and find out why.