The operators that are used to identify the logic between two operands or variables are called logical operators in the pine script programming language.

In pine script, there are mainly three types of logical operators.

- Negation (not)
- Conjunction (and)
- Disjunction (or)

Each of the three logical operators has different functions. Logical operators can be used with Boolean, numbers, and series. In other programming languages, symbols of logical operators are used. But in pine script, they are used as it is. Like written above (not, and, or).

## Negation (not) logical operator in pine script

Negation (not) operator refers to the operators that completely reverse the sense of an operand. If the negation (not) operator is applied to a true value, then it will return a false value and vice versa. Negation operator is applied to one operand to reverse its sense.

Numbers and floats will always return a true value. So, if the negation (not) operator is multiplied with a number or float then it will return a false value either a positive number or a negative number.

If the negation operator is multiplied by series, then it will return a true or false value in series. If a series contain a number or float, then it will return a false value after multiplying with the negation operator. Because number or float return true value always. At some point, it can also return a false value due to na operand. So, it depends.

```
// Negation not
a_1 = not true // false
a_2 = not false // true
a_3 = not 2 // false
a_4 = not 3.0 // false
a_5 = not na // true
a_6 = not open // [true,false]
```

## Conjunction (and) logical operator in pine script

A logical operator that will return a false value if any of its operands has a false value is called Conjunction (and) operator. It is applied between two operands. It is also applied to Boolean, numbers, and series.

Conjunction (and) operator will return true value only if both are true. Numbers and floats are always true. Na variable is always false.

In open series most of the time it will return true in series but in some cases, due to na variable it will also return a false value in series. Because in an open variable, there are floats (currency opening prices) in series that always return a true value.

```
// Conjunction and
a_1 = true and true // true
a_2 = true and false // false
a_3 = false and false // false
a_4 = 2 and 3.0 // true
a_6 = open and close // [true,false]
```

## Disjunction (or) operator in pine script

A logical operator that will return a true value if any of its operands has a true value is called a disjunction (or) logical operator.

Disjunction operator can be applied at numbers, floats, Boolean, and series.

```
// Disjunction or
a_1 = true or true // true
a_2 = true or false // true
a_3 = false or false // false
a_4 = 2 or 3.0 // true
a_6 = low or high // [true,false]
```

I hope you will like this Article. For any Questions Comment below, also share by below links. Open Tradingview Chart

**Note:** All the viewpoints here are according to the rules of technical analysis. we are not responsible for any type of loss in forex trading.