XOR in mql4

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

Yes...see Bitwise Operations.
Michael Kroeker
168
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
6519
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
jack zorlob
19
jack zorlob  
Azael05x:
I really cant find it in reference... Is there XOR?

xor is  if int a,b

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

William Roeder
25075
William Roeder  
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.