Reference: Drawing

Vex reference: drawing.

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

NameWhat
nameNames the script (the legend and menus show it). where = chooses the price chart or its own pane; without it, Vex decides.
plotDraws a value. The color may be a formula, picking one per bar. offset = n draws it n bars ahead (past the newest bar) or back (negative).
levelGrey dashed horizontal lines at fixed values (numbers or settings).
fillFills between two lines: up color where a is above b, down below, unless a color is given. The color may be a formula, one per bar (a ribbon). opacity is how solid it is (default 12); a #rrggbbaa color keeps its own.
markMarks the bars where a yes/no is true. Add "and closed" to mark finished bars only. at = price puts it at a price (a label); {name} in the text shows a value; offset = -n draws it n bars back.
alertAlerts when a bar closes with the condition true, while a chart running the script is open (your alert settings decide sound and notifications). {name} puts a value in the message.
bar_colorColors the chart's candles per bar (none leaves a bar as it is).
backgroundColors behind each bar; use a see-through color (#rrggbbaa).

name

1name("title", where = chart|pane)

Names the script (the legend and menus show it). where = chooses the price chart or its own pane; without it, Vex decides.

In Pine Script: indicator(title, overlay = true)

Example

1name("EMA 21", where = chart)2plot(ema(close, 21))

plot

1plot(value, "title", color = c, width = 1-4, style = line|bars|dots|steps, offset = n)

Draws a value. The color may be a formula, picking one per bar. offset = n draws it n bars ahead (past the newest bar) or back (negative).

In Pine Script: plot(series, title, color, linewidth, style, offset)

Example

1plot(rsi(close, 14), "RSI", color = blue, width = 2)2plot(volume, "Volume", style = bars, color = close > open ? up : down)

See also: Drawing, Colors

level

1level(a, b, ...)

Grey dashed horizontal lines at fixed values (numbers or settings).

In Pine Script: hline(price)

Example

1plot(rsi(close, 14))2level(70, 50, 30)

fill

1fill(a, b, color = c, opacity = 0-100, offset = n)

Fills between two lines: up color where a is above b, down below, unless a color is given. The color may be a formula, one per bar (a ribbon). opacity is how solid it is (default 12); a #rrggbbaa color keeps its own.

With a color formula the fill is a ribbon: each stretch takes the color of the bar it starts from, as the lines do.

opacity sets how solid it is, 0 to 100 (default 12); it is also a setting on the Style tab. A #rrggbbaa color keeps its own transparency.

In Pine Script: fill(plot1, plot2, color)

Example

1name("Ribbon", where = chart)2 3fast = ema(close, 9)4slow = ema(close, 21)5plot(fast)6plot(slow)7fill(fast, slow, color = fast > slow ? green : red, opacity = 35)

See also: Colors

mark

1mark(condition, "text {name}", where = above|below, shape = arrow|dot, color = c, at = price, offset = -n)

Marks the bars where a yes/no is true. Add "and closed" to mark finished bars only. at = price puts it at a price (a label); {name} in the text shows a value; offset = -n draws it n bars back.

at = price puts the mark at that price: a label. {name} in its text shows the value on that bar, as alert messages do (up to 40 characters). offset = -n draws it n bars back, so a pivot found right bars later is labelled on its own bar.

In Pine Script: plotshape(condition, text, location, style, color); label.new(x, y, text)

Example

1fast = ema(close, 9)2slow = ema(close, 21)3plot(fast)4plot(slow)5mark(crosses_above(fast, slow) and closed, "B", where = below)6mark(crosses_below(fast, slow) and closed, "S", where = above, shape = dot, color = orange)

See also: Marks, finished bars and alerts

alert

1alert(condition, "message {name}")

Alerts when a bar closes with the condition true, while a chart running the script is open (your alert settings decide sound and notifications). {name} puts a value in the message.

In Pine Script: alertcondition(condition, title, message)

Example

1fast = ema(close, 9)2slow = ema(close, 21)3plot(fast)4plot(slow)5alert(crosses_above(fast, slow), "Fast crossed above slow at {close}")

See also: Marks, finished bars and alerts

bar_color

1bar_color(color)

Colors the chart's candles per bar (none leaves a bar as it is).

In Pine Script: barcolor(color)

Example

1bar_color(close > ema(close, 50) ? up : down)

background

1background(color)

Colors behind each bar; use a see-through color (#rrggbbaa).

In Pine Script: bgcolor(color)

Example

1background(rsi(close, 14) > 70 ? #ef444420 : none)