You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
answer #3 seems to be the best - with x & y as conditions & b as overall result (as for XOR)... with such a tip (^) no any violation of XOR logics was noticed by me in real coding in MQL
The issue lies within the type of operation to be performed.
logical operators "do not" support XOR as a separate type, it is represented with unequal, as shown.
Let me give you an example of arithmetic/bitwise and logical operation:
As you can see, the interpretation depends on the type.
So when the code is using logical operators "&&", the result is different to the bitwise/arithmetic approach.
This is an important distinguishment.
XOR = A != B
My mistake in this reply was not to give the types, as I interpreted them to be bool.
In fact, if not specified, mql compiler defaults to type "int", since there is no type giving operator in place. This is different for the statement
Here the type is given by the logical operator, interpreting the values A and B as logical "true" and "false" values. Since the "&&" operator is specific to the type "bool".
ok, I will check_ once again. Thanks