Sidechair

not

Browse the reference

Logical negation: not x is true when x is false, and false when x is true.

Try it in the editor

not takes one bool and flips it. It binds tighter than and and or, so not a and b is (not a) and b; use brackets to negate a whole expression, as in not (a and b).

Typical uses are not na(x), to test that a value exists, and not barstate.isfirst. In v6 the operand must be a bool, and a bool is never na, so not never returns na.

Syntax

not expr1

Remarks

  • On Sidechair: not treats a number as true when non-zero, so not 0 is true.

Example

Pine ScriptOnly when the value existsOpen in editor
//@version=6
indicator("Not", overlay = true)
ph = ta.pivothigh(high, 3, 3)
plotshape(not na(ph), "Pivot high", shape.triangledown, location.abovebar, color.red, offset = -3)
bgcolor(not barstate.isconfirmed ? color.new(color.gray, 85) : na)

See also

Runs on Sidechair