Reference: Formulas

Vex reference: formulas.

For AI tools: this page as Markdown · the whole language in one file

NameWhat
ifPicks a value per bar. condition ? a : b is the same.
startsWhat prev(name) reads before there is an earlier bar.
noneNo value (an empty bar, no color).
andBoth are true.
orEither is true. Between texts at the top level, a list of choices for a setting.
notThe opposite yes/no.

if

1if condition then a else b

Picks a value per bar. condition ? a : b is the same.

In Pine Script: condition ? a : b

Example

1plot(close > open ? high : low)2plot(if close > open then 1 else -1, "Up or down", style = steps)

See also: Picking a value: if and ? :

starts

1name starts value

What prev(name) reads before there is an earlier bar.

In Pine Script: var x = value

Example

1n starts 02n = new_day ? 0 : prev(n) + 13plot(n, "Bars into the day", style = steps)

See also: Values that carry over: starts

none

No value (an empty bar, no color).

In Pine Script: na

Example

1plot(close > open ? close : none, style = dots)

See also: Empty values

and

1a and b

Both are true.

Example

1plot(close)2mark(close > open and volume > sma(volume, 20), where = below, shape = dot)

or

1a or b

Either is true. Between texts at the top level, a list of choices for a setting.

Example

1plot(close)2mark(new_day or crosses_above(close, ema(close, 50)), where = below, shape = dot)

not

1not a

The opposite yes/no.

Example

1plot(close)2mark(not (close > open), where = above, shape = dot)