# XOR in mql4

77

I really cant find it in reference... Is there XOR?
369

Azael05x:
I really cant find it in reference... Is there XOR?

Yes...see Bitwise Operations.
168

Haha got stumped for a minute or two on this one as well first time needed XOR in MQL.

Just use the not equal Operation: !=

for example if(x != y){...}

x
y
Result
false
false
false
false
true
true
true
false
true
true
true
false

6519

Michael Kroeker:

Haha got stumped for a minute or two on this one as well first time needed XOR in MQL.

Just use the not equal Operation: !=

for example if(x != y){...}

The correct answer was given in the post above yours, namely Bitwise Operations! "Not equal to" (!=) is not the same as XOR:

### Bitwise Exclusive Operation OR

The bitwise exclusive OR (eXclusive OR) operation of binary representations of x and y. The value of the expression contains a 1 in all digits where x and y have different binary values, and it contains 0 in all other digits.

 b = x ^ y

Bitwise Operations - Operations and Expressions - Language Basics - MQL4 Reference
• docs.mql4.com
Bitwise Operations - Operations and Expressions - Language Basics - MQL4 Reference
19

Azael05x:
I really cant find it in reference... Is there XOR?

xor is  if int a,b

xor=(a&&!b)||(!a&&b)

25075

jack zorlob: xor=(a&&!b)||(!a&&b)
Do you really expect that people are still watching this thread after four (4) years?
Don't resurrect old threads without a very good reason.