Download MetaTrader 5

XOR in mql4

To add comments, please log in or register
Azael05x
75
Azael05x  
I really cant find it in reference... Is there XOR?
GreenMoney
379
GreenMoney  
Azael05x:
I really cant find it in reference... Is there XOR?

Yes...see Bitwise Operations.
Michael Kroeker
162
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){...}

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


Fernando Carreiro
3916
Fernando Carreiro  
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
Bitwise Operations - Operations and Expressions - Language Basics - MQL4 Reference
  • docs.mql4.com
Bitwise Operations - Operations and Expressions - Language Basics - MQL4 Reference
To add comments, please log in or register