# Operators and expressions

> and, or, not, between, in, if-then-else.

Source: https://algobarsx.com/docs/operators/

```algobarsx
in_band = rsi(close, 14) between 40 and 60
morning = hour in 8..11
bias = if close > ema(close, 200) then 1 else -1
power = 2 ** 3
calm = not (atr(14) > atr(14)[10])
first_hour = time_of_day between 08:00 and 09:00
```

| Operator | Meaning |
| --- | --- |
| `+ - * / % **` | Arithmetic. `**` is power and groups from the right, so `2 ** 3 ** 2` is 512. |
| `== != < <= > >=` | Comparison. |
| `and or not` | Logic, in words. |
| `x between a and b` | True when `x` is inside the range. |
| `x in 8..11` | True when `x` is in a range or a list. |
| `if c then a else b` | Chooses a value inside an expression. |
| `2% of account.balance` | Turns a percent into an amount. |
| `+= -= *= /=` | Update a `state` value in place. |

Time variables available everywhere: `hour`, `minute`, `day_of_week` and `time_of_day`.
