Logical AND: a and b is true only when both are true, and in v6 b is not evaluated when a is already false.
and combines two bool values and gives true only when both are true. It binds tighter than or and looser than not and the comparison operators, so close > open and volume > 0 reads as expected.
In v6 evaluation is lazy: if the left side is false, the right side is not evaluated at all. That lets you guard a check, as in i < array.size(a) and array.get(a, i) > 0. In v5 both sides always ran.
Syntax
expr1 and expr2Remarks
- Lazy evaluation also means a function call on the right side may not run on a given bar. If it keeps state across bars, such as a ta.* call, put it on its own line so it runs every bar.
- On Sidechair: and short-circuits in v6 scripts and evaluates both sides in v5 scripts, as standard Pine does.
Example
//@version=6
indicator("And", overlay = true)
trendUp = ta.sma(close, 20) > ta.sma(close, 50)
pullback = close < ta.sma(close, 20)
plotshape(trendUp and pullback, "Buy the dip", shape.triangleup, location.belowbar, color.green)
plot(ta.sma(close, 20), "SMA 20", color.blue)See also
Runs on Sidechair