?: - Pine Script Operator
?:
Overview
Section titled “Overview”Ternary conditional operator.
Syntax
Section titled “Syntax”expr1 ? expr2 : expr3Returns
Section titled “Returns”expr2 if expr1 is evaluated to true, expr3 otherwise. Zero value (0 and also NaN, +Infinity, -Infinity) is considered to be false, any other value is true.
Remarks
Section titled “Remarks”- Use na for ‘else’ branch if you do not need it.
Example
Section titled “Example”//@version=6indicator("?:")// Draw circles at the bars where open crosses closes2 = ta.cross(open, close) ? math.avg(open,close) : naplot(s2, style=plot.style_circles, linewidth=2, color=color.red)// Combination of ?: operators for 'switch'-like logicc = timeframe.isintraday ? color.red : timeframe.isdaily ? color.green : timeframe.isweekly ? color.blue : color.grayplot(hl2, color=c)