The type for true or false. Comparisons produce bools, and conditions in if, ternaries and plotshape consume them.
A bool is either true or false. Every comparison (>, <, ==, !=) and logical operator (and, or, not) produces one, and so do many built-ins such as ta.crossover() and barstate.islast.
In v6 a bool is never na: a value that would be na is treated as false, and an if condition must be a real bool, not a number. In v5 and earlier a number in a condition is accepted, with 0 and na counting as false.
Remarks
- bool(x) casts a number: 0 and na become false, anything else becomes true.
- An alertcondition() or plotshape() condition reads a series bool, and a bool also picks the colour you give bgcolor(), so a bool computed on each bar is how you mark the bars you care about.
- On Sidechair: bool(x) is true for a non-zero number and false for 0 and na.
Example
//@version=6
indicator("Up and above average", overlay = true)
avg = ta.sma(close, 20)
signal = close > open and close > avg
plot(avg, "SMA 20", color.gray)
plotshape(signal, "Signal", shape.triangleup, location.belowbar, color.green, size = size.small)See also
Runs on Sidechair