XOR

Category: Operators

The XOR (eXclusive OR) is a logical operator used in the ProBuilder programming language. It is primarily used to compare two conditions and returns true if exactly one of the conditions is true, but not both. This operator is useful in scenarios where you need to ensure that only one of multiple possible conditions is met.

Syntax:

result = expression1 XOR expression2

Example:

a = 5
b = 7
c = 6
IF (c > a XOR c > b) THEN
    result = 1
ELSE
    result = 0
ENDIF
RETURN result

In this example, the XOR operator is used to evaluate whether c is greater than either a or b, but not both. Since c is greater than a but not b, the condition c > a XOR c > b evaluates to true, and result is set to 1.

  • The XOR operator is particularly useful in decision-making processes where exclusivity is required between two conditions.
  • It is important to note that if both conditions are true or both are false, the result of the XOR operation will be false.

This operator helps in creating more complex logical conditions in your trading algorithms, allowing for precise control over when certain actions should be executed based on exclusive conditions.

Related Instructions:

  • AND operators
  • OR operators
  • Logo Logo
    Loading...