# Vex reference: every function

Every function, value and color in Vex, by section. Each entry has its signature, arguments, what it returns and an example.

## Settings

### int

```vex
int(14, "Label", min =, max =, step =)
```

A whole-number setting with its own label and limits (at the top of the script).

**In Pine Script:** `input.int(defval, title, minval, maxval, step)`

**Example**

```vex
length = int(14, "RSI length", min = 2, max = 200)
plot(rsi(close, length))
```

### float

```vex
float(2, "Label", min =, max =, step =)
```

A decimal setting with its own label and limits.

**In Pine Script:** `input.float(defval, title, minval, maxval, step)`

**Example**

```vex
mult = float(2, "Width", min = 0.5, step = 0.25)
b = bands(close, 20, mult)
plot(b.upper)
plot(b.lower)
```

### bool

```vex
bool(true, "Label")
```

A checkbox setting.

**In Pine Script:** `input.bool(defval, title)`

**Example**

```vex
smooth = bool(true, "Smooth it")
plot(smooth ? ema(close, 9) : close)
```

### string

```vex
string("a" or "b", "Label")
```

A dropdown of choices; the first is the default.

**In Pine Script:** `input.string(defval, title, options)`

**Example**

```vex
average = string("ema" or "sma", "Average")
plot(average == "ema" ? ema(close, 20) : sma(close, 20))
```

### source

```vex
source(close, "Label")
```

A price setting (close, open, high, low, hl2, hlc3, ohlc4).

**In Pine Script:** `input.source(defval, title)`

**Example**

```vex
src = source(close, "Price")
plot(ema(src, 20))
```

### color

```vex
color(blue, "Label")
```

A color setting.

**In Pine Script:** `input.color(defval, title)`

**Example**

```vex
col = color(blue, "Line color")
plot(ema(close, 20), color = col)
```

## Drawing

### name

```vex
name("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**

```vex
name("EMA 21", where = chart)
plot(ema(close, 21))
```

### plot

```vex
plot(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**

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

See also: [Drawing](/documentation/vex/drawing), [Colors](/documentation/vex/colors)

### level

```vex
level(a, b, ...)
```

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

**In Pine Script:** `hline(price)`

**Example**

```vex
plot(rsi(close, 14))
level(70, 50, 30)
```

### fill

```vex
fill(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**

```vex
name("Ribbon", where = chart)

fast = ema(close, 9)
slow = ema(close, 21)
plot(fast)
plot(slow)
fill(fast, slow, color = fast > slow ? green : red, opacity = 35)
```

See also: [Colors](/documentation/vex/colors)

### mark

```vex
mark(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**

```vex
fast = ema(close, 9)
slow = ema(close, 21)
plot(fast)
plot(slow)
mark(crosses_above(fast, slow) and closed, "B", where = below)
mark(crosses_below(fast, slow) and closed, "S", where = above, shape = dot, color = orange)
```

See also: [Marks, finished bars and alerts](/documentation/vex/marks-finished-bars-and-alerts)

### alert

```vex
alert(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**

```vex
fast = ema(close, 9)
slow = ema(close, 21)
plot(fast)
plot(slow)
alert(crosses_above(fast, slow), "Fast crossed above slow at {close}")
```

See also: [Marks, finished bars and alerts](/documentation/vex/marks-finished-bars-and-alerts)

### bar_color

```vex
bar_color(color)
```

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

**In Pine Script:** `barcolor(color)`

**Example**

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

### background

```vex
background(color)
```

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

**In Pine Script:** `bgcolor(color)`

**Example**

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

## Formulas

### if

```vex
if condition then a else b
```

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

**In Pine Script:** `condition ? a : b`

**Example**

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

See also: [Picking a value: if and ? :](/documentation/vex/picking-a-value-if-and)

### starts

```vex
name starts value
```

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

**In Pine Script:** `var x = value`

**Example**

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

See also: [Values that carry over: starts](/documentation/vex/values-that-carry-over-starts)

### none

No value (an empty bar, no color).

**In Pine Script:** `na`

**Example**

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

See also: [Empty values](/documentation/vex/empty-values)

### and

```vex
a and b
```

Both are true.

**Example**

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

### or

```vex
a or b
```

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

**Example**

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

### not

```vex
not a
```

The opposite yes/no.

**Example**

```vex
plot(close)
mark(not (close > open), where = above, shape = dot)
```

## Bar values

### open

The bar's open.

**Returns:** a number per bar

**Example**

```vex
plot(open)
```

### high

The bar's high.

**Returns:** a number per bar

**Example**

```vex
plot(high)
```

### low

The bar's low.

**Returns:** a number per bar

**Example**

```vex
plot(low)
```

### close

The bar's close (the latest price on the forming bar).

**Returns:** a number per bar

**Example**

```vex
plot(close)
```

### volume

The bar's volume (empty where the chart has none).

**Returns:** a number per bar

**Example**

```vex
plot(volume)
```

### time

When the bar opened, in seconds since 1970 (UTC).

Pine's time is in milliseconds; Vex's is in seconds.

**Returns:** a number per bar

**In Pine Script:** `time / 1000`

**Example**

```vex
plot(time)
```

### bar

The bar number: 0 for the first bar loaded, then 1, 2, ...

**Returns:** a number per bar

**In Pine Script:** `bar_index`

**Example**

```vex
plot(bar)
```

### hl2

(high + low) / 2

**Returns:** a number per bar

**Example**

```vex
plot(hl2)
```

### hlc3

(high + low + close) / 3

**Returns:** a number per bar

**Example**

```vex
plot(hlc3)
```

### ohlc4

(open + high + low + close) / 4

**Returns:** a number per bar

**Example**

```vex
plot(ohlc4)
```

### tr

True range: the bar's range including any gap from the previous close.

**Returns:** a number per bar

**In Pine Script:** `ta.tr`

**Example**

```vex
plot(tr)
```

### buy_volume

Volume bought by takers in the bar (crypto; empty where the chart has none).

**Returns:** a number per bar

**Example**

```vex
plot(buy_volume)
```

### sell_volume

Volume sold by takers in the bar (crypto; empty where the chart has none).

**Returns:** a number per bar

**Example**

```vex
plot(sell_volume)
```

### delta

buy_volume - sell_volume: the bar's taker delta.

**Returns:** a number per bar

**Example**

```vex
plot(delta)
```

### cvd

Cumulative volume delta: total(delta) from the first bar loaded.

**Returns:** a number per bar

**Example**

```vex
plot(cvd)
```

### obv

On-balance volume: running volume, added on up closes and taken off on down closes.

**Returns:** a number per bar

**In Pine Script:** `ta.obv`

**Example**

```vex
plot(obv)
```

### vwap

Volume-weighted average price of the session (resets each UTC day), on hlc3.

**Returns:** a number per bar

**In Pine Script:** `ta.vwap`

**Example**

```vex
plot(vwap)
```

### hour

Hour of the bar's open, 0 to 23 (UTC).

**Returns:** a number per bar

**In Pine Script:** `hour(time, "UTC")`

**Example**

```vex
background(hour >= 13 and hour < 21 ? #3b82f615 : none)
```

### minute

Minute of the bar's open, 0 to 59.

**Returns:** a number per bar

**In Pine Script:** `minute(time, "UTC")`

**Example**

```vex
plot(minute)
```

### weekday

Day of the week of the bar's open: 1 Monday to 7 Sunday (UTC).

Pine counts Sunday as 1; Vex counts Monday as 1 and Sunday as 7.

**Returns:** a number per bar

**In Pine Script:** `dayofweek`

**Example**

```vex
plot(weekday)
```

### new_day

True on the first bar of each UTC day (and the first bar loaded).

**Returns:** a yes/no per bar

**In Pine Script:** `ta.change(time("D")) != 0`

**Example**

```vex
background(new_day ? #3b82f630 : none)
```

### closed

True once the bar is final; false on the bar still forming. Use "and closed" so a mark or alert only fires on finished bars (no repainting).

**Returns:** a yes/no per bar

**In Pine Script:** `barstate.isconfirmed`

**Example**

```vex
fast = ema(close, 9)
slow = ema(close, 21)
plot(fast)
plot(slow)
mark(crosses_above(fast, slow) and closed, "B", where = below)
```

See also: [Marks, finished bars and alerts](/documentation/vex/marks-finished-bars-and-alerts)

## BackQuant data

### gex

Net dealer gamma exposure (flow-signed, all expiries), in $ per 1% move. Crypto only.

**Returns:** a number per bar

**Example**

```vex
g = gex / 1e9
plot(g, "Net GEX ($bn)", style = bars, color = g > 0 ? up : down)
level(0)
```

### oi

Open interest, all venues, in $ (BTC, ETH, SOL, HYPE).

**Returns:** a number per bar

**Example**

```vex
plot(oi / 1e9, "OI ($bn)")
```

### funding

Funding rate across venues, in basis points per 8 hours (BTC, ETH, SOL, HYPE).

**Returns:** a number per bar

**Example**

```vex
plot(funding, "Funding (bp / 8h)", style = bars, color = funding > 0 ? up : down)
level(0)
```

### liq_long

Long positions liquidated in the bar, in $ (BTC, ETH, SOL, HYPE).

**Returns:** a number per bar

**Example**

```vex
plot(liq_long / 1e6, "Longs liquidated ($m)", style = bars, color = down)
plot(-liq_short / 1e6, "Shorts liquidated ($m)", style = bars, color = up)
```

### liq_short

Short positions liquidated in the bar, in $ (BTC, ETH, SOL, HYPE).

**Returns:** a number per bar

**Example**

```vex
plot(liq_short / 1e6, "Shorts liquidated ($m)", style = bars, color = up)
```

### iv

Implied volatility: DVOL, in percent (BTC and ETH).

**Returns:** a number per bar

**Example**

```vex
plot(iv, "IV")
plot(sma(iv, 30), "30-bar average")
```

### prem_calls

Net call premium in the bar (bought minus sold), in $ (BTC and ETH).

**Returns:** a number per bar

**Example**

```vex
plot((prem_calls - prem_puts) / 1e6, "Net premium ($m)", style = bars, color = prem_calls > prem_puts ? up : down)
```

### prem_puts

Net put premium in the bar (bought minus sold), in $ (BTC and ETH).

**Returns:** a number per bar

**Example**

```vex
plot(prem_puts)
```

### gamma_flip

The gamma flip (HVL): the price nearest spot where cumulative dealer gamma changes sign, from the same dealer book as gex (Flow, all expiries; empty with no crossing within 25%). Crypto only.

Each bar has the flip of the dealer book in force at its close, from the same history as the chart's gamma levels: never a level from the future. Further back the history is coarser (the server spaces snapshots to fit the window).

**Returns:** a number per bar

**Example**

```vex
name("Gamma flip", where = chart)

plot(gamma_flip, "Gamma flip", color = orange, style = steps)
background(close > gamma_flip ? #22c55e0d : #ef44440d)
```

See also: [call_wall](/documentation/vex/reference/backquant-data#call-wall), [put_wall](/documentation/vex/reference/backquant-data#put-wall), [gex](/documentation/vex/reference/backquant-data#gex)

### call_wall

The call wall: the strike above the price with the largest positive dealer gamma (Flow, all expiries). Crypto only.

**Returns:** a number per bar

**Example**

```vex
name("Call wall", where = chart)

plot(call_wall, "Call wall", color = green, style = steps)
mark(crosses_above(close, call_wall) and closed, "C", where = below)
```

See also: [put_wall](/documentation/vex/reference/backquant-data#put-wall), [gamma_flip](/documentation/vex/reference/backquant-data#gamma-flip)

### put_wall

The put wall: the strike below the price with the largest positive dealer gamma (Flow, all expiries). Crypto only.

**Returns:** a number per bar

**Example**

```vex
name("Put wall", where = chart)

plot(put_wall, "Put wall", color = red, style = steps)
mark(crosses_below(close, put_wall) and closed, "P", where = above)
```

See also: [call_wall](/documentation/vex/reference/backquant-data#call-wall), [gamma_flip](/documentation/vex/reference/backquant-data#gamma-flip)

### etf_flow

Net creations into the US spot ETFs, in $ per day (BTC, ETH, SOL, XRP; daily, lined up with the bars).

**Returns:** a number per bar

**Example**

```vex
plot(etf_flow / 1e6, "ETF flow ($m)", style = bars, color = etf_flow > 0 ? up : down)
plot(sum(etf_flow, 5) / 1e6, "5-day total ($m)", color = orange)
```

### rv

Realised volatility, in percent: what price has done, to set against iv (BTC and ETH, daily).

**Returns:** a number per bar

**Example**

```vex
plot(iv - rv, "Vol premium (IV - RV)", style = bars, color = iv > rv ? up : down)
level(0)
```

See also: [iv](/documentation/vex/reference/backquant-data#iv)

### rr25

30-day 25-delta risk reversal: call IV minus put IV, in vol points (above 0, calls are pricier). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(rr25, "25d risk reversal (30d)", style = bars, color = rr25 > 0 ? up : down)
level(0)
```

See also: [fly25](/documentation/vex/reference/backquant-data#fly25), [iv](/documentation/vex/reference/backquant-data#iv)

### fly25

30-day 25-delta butterfly: how much the wings cost over ATM, in vol points. Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(fly25, "25d butterfly (30d)")
```

See also: [rr25](/documentation/vex/reference/backquant-data#rr25)

### basis

The perp aggregate over the spot aggregate, in basis points (above 0, perps trade rich). Crypto.

**Returns:** a number per bar

**Example**

```vex
plot(basis, "Basis (bps)", style = bars, color = basis > 0 ? up : down)
level(0)
```

### cb_premium

Coinbase's USD price over Binance's USDT price, in percent (above 0, US buyers pay up). BTC, ETH, SOL.

**Returns:** a number per bar

**Example**

```vex
plot(cb_premium, "Coinbase premium (%)", style = bars, color = cb_premium > 0 ? up : down)
level(0)
```

### put_call

Puts' open interest over calls' (above 1, more puts open). BTC and ETH, daily.

**Returns:** a number per bar

**Example**

```vex
plot(put_call, "Put/call OI")
level(1)
```

### short_share

The share of the day's volume reported as short sales on FINRA venues, in percent. US equities, daily.

**Returns:** a number per bar

**Example**

```vex
plot(short_share, "Short % of volume")
plot(sma(short_share, 20), "20-day average", color = orange)
level(50)
```

### gex_0dte

Net dealer gamma exposure, in $ per 1% move (flow-signed, the front expiry while it expires within a day (0DTE), else empty). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(gex_0dte)
```

### gex_front

Net dealer gamma exposure, in $ per 1% move (flow-signed, the front (nearest) expiry). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(gex_front)
```

### gex_week

Net dealer gamma exposure, in $ per 1% move (flow-signed, expiries within 7 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(gex_week)
```

### gex_month

Net dealer gamma exposure, in $ per 1% move (flow-signed, expiries within 31 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(gex_month)
```

### dex

Net dealer delta, in $ (flow-signed, all expiries). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(dex)
```

### dex_0dte

Net dealer delta, in $ (flow-signed, the front expiry while it expires within a day (0DTE), else empty). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(dex_0dte)
```

### dex_front

Net dealer delta, in $ (flow-signed, the front (nearest) expiry). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(dex_front)
```

### dex_week

Net dealer delta, in $ (flow-signed, expiries within 7 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(dex_week)
```

### dex_month

Net dealer delta, in $ (flow-signed, expiries within 31 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(dex_month)
```

### vanna

Net dealer vanna (VEX): how dealer delta moves when implied vol moves, in $ of delta per vol point (flow-signed, all expiries). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vanna)
```

### vanna_0dte

Net dealer vanna (VEX): how dealer delta moves when implied vol moves, in $ of delta per vol point (flow-signed, the front expiry while it expires within a day (0DTE), else empty). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vanna_0dte)
```

### vanna_front

Net dealer vanna (VEX): how dealer delta moves when implied vol moves, in $ of delta per vol point (flow-signed, the front (nearest) expiry). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vanna_front)
```

### vanna_week

Net dealer vanna (VEX): how dealer delta moves when implied vol moves, in $ of delta per vol point (flow-signed, expiries within 7 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vanna_week)
```

### vanna_month

Net dealer vanna (VEX): how dealer delta moves when implied vol moves, in $ of delta per vol point (flow-signed, expiries within 31 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vanna_month)
```

### charm

Net dealer charm (CEX): how dealer delta drifts as time passes, in $ of delta per day (flow-signed, all expiries). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(charm)
```

### charm_0dte

Net dealer charm (CEX): how dealer delta drifts as time passes, in $ of delta per day (flow-signed, the front expiry while it expires within a day (0DTE), else empty). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(charm_0dte)
```

### charm_front

Net dealer charm (CEX): how dealer delta drifts as time passes, in $ of delta per day (flow-signed, the front (nearest) expiry). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(charm_front)
```

### charm_week

Net dealer charm (CEX): how dealer delta drifts as time passes, in $ of delta per day (flow-signed, expiries within 7 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(charm_week)
```

### charm_month

Net dealer charm (CEX): how dealer delta drifts as time passes, in $ of delta per day (flow-signed, expiries within 31 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(charm_month)
```

### vega

Net dealer vega, in $ per vol point (flow-signed, all expiries). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vega)
```

### vega_0dte

Net dealer vega, in $ per vol point (flow-signed, the front expiry while it expires within a day (0DTE), else empty). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vega_0dte)
```

### vega_front

Net dealer vega, in $ per vol point (flow-signed, the front (nearest) expiry). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vega_front)
```

### vega_week

Net dealer vega, in $ per vol point (flow-signed, expiries within 7 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vega_week)
```

### vega_month

Net dealer vega, in $ per vol point (flow-signed, expiries within 31 days). Crypto only.

**Returns:** a number per bar

**Example**

```vex
plot(vega_month)
```

## Averages

### sma

```vex
sma(x, n)
```

Simple moving average of x over n bars.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.sma(source, length)`

**Example**

```vex
plot(sma(close, 20))
```

See also: [ema](/documentation/vex/reference/averages#ema), [wma](/documentation/vex/reference/averages#wma)

### ema

```vex
ema(x, n)
```

Exponential moving average of x over n bars (seeded with the SMA).

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.ema(source, length)`

**Example**

```vex
plot(ema(close, 21))
```

See also: [sma](/documentation/vex/reference/averages#sma), [rma](/documentation/vex/reference/averages#rma)

### rma

```vex
rma(x, n)
```

Wilder's moving average (the one RSI and ATR use).

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.rma(source, length)`

**Example**

```vex
gain = max(close - prev(close), 0)
plot(rma(gain, 14), "Average gain")
```

See also: [rsi](/documentation/vex/reference/indicators#rsi), [atr](/documentation/vex/reference/indicators#atr)

### wma

```vex
wma(x, n)
```

Weighted moving average: the newest bar weighs n, the oldest 1.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.wma(source, length)`

**Example**

```vex
plot(wma(close, 9))
```

### dema

```vex
dema(x, n)
```

Double EMA: 2 x ema(x, n) - ema(ema(x, n), n), quicker to turn than an EMA.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.dema(source, length) (ta library)`

**Example**

```vex
plot(dema(close, 20))
```

### tema

```vex
tema(x, n)
```

Triple EMA: 3 x e1 - 3 x e2 + e3 for an EMA taken one, two and three times.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.tema(source, length) (ta library)`

**Example**

```vex
plot(tema(close, 20))
```

### t3

```vex
t3(x, n, vf = 0.7)
```

Tillson T3: six EMAs blended by the volume factor vf (0.7 as usual), smooth with little lag.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting
- `vf`: a number fixed when the script runs: a number or a setting; 0.7 when left out

**Returns:** a number per bar

**In Pine Script:** `ta.t3(source, length, volumeFactor) (ta library)`

**Example**

```vex
plot(t3(close, 5, 0.7), "T3")
plot(ema(close, 5), "EMA", color = grey)
```

### alma

```vex
alma(x, n, offset = 0.85, sigma = 6)
```

Arnaud Legoux moving average: Gaussian weights centred offset of the way from the oldest bar (0.85 leans to the newest), as wide as n / sigma.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting
- `offset`: a number fixed when the script runs: a number or a setting; 0.85 when left out
- `sigma`: a number fixed when the script runs: a number or a setting; 6 when left out

**Returns:** a number per bar

**In Pine Script:** `ta.alma(source, length, offset, sigma)`

**Example**

```vex
plot(alma(close, 9, 0.85, 6))
```

### hma

```vex
hma(x, n)
```

Hull moving average: smooth and quick to turn.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.hma(source, length)`

**Example**

```vex
name("Hull", where = chart)

f = hma(close, 55)
s = prev(f, 2)
plot(f, "Hull", color = f > s ? #00ff00 : #ff0000)
plot(s, "Hull 2", color = f > s ? #00ff00 : #ff0000)
fill(f, s, color = f > s ? #00ff00 : #ff0000, opacity = 40)
```

### vwma

```vex
vwma(x, n)
```

Volume-weighted moving average.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.vwma(source, length)`

**Example**

```vex
plot(vwma(close, 20))
```

## Windows

### highest

```vex
highest(x, n)
```

The highest x over the last n bars.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.highest(source, length)`

**Example**

```vex
plot(highest(high, 20))
```

See also: [lowest](/documentation/vex/reference/windows#lowest), [donchian](/documentation/vex/reference/indicators#donchian)

### lowest

```vex
lowest(x, n)
```

The lowest x over the last n bars.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.lowest(source, length)`

**Example**

```vex
plot(lowest(low, 20))
```

See also: [highest](/documentation/vex/reference/windows#highest), [donchian](/documentation/vex/reference/indicators#donchian)

### sum

```vex
sum(x, n)
```

The total of x over the last n bars.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `math.sum(source, length)`

**Example**

```vex
plot(sum(volume, 24))
```

See also: [total](/documentation/vex/reference/windows#total), [count](/documentation/vex/reference/events#count)

### stdev

```vex
stdev(x, n)
```

Standard deviation of x over the last n bars (population).

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.stdev(source, length)`

**Example**

```vex
plot(stdev(close, 20))
```

### change

```vex
change(x, n = 1)
```

How much x moved over n bars: x - prev(x, n).

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 1 when left out

**Returns:** a number per bar

**In Pine Script:** `ta.change(source, length)`

**Example**

```vex
plot(change(close))
```

### roc

```vex
roc(x, n)
```

Rate of change: percent move of x over n bars.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.roc(source, length)`

**Example**

```vex
plot(roc(close, 10))
```

### total

```vex
total(x)
```

Running total of x from the first bar (empty values add nothing).

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `ta.cum(source)`

**Example**

```vex
plot(total(volume))
```

### median

```vex
median(x, n)
```

The middle value of x over the last n bars.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.median(source, length)`

**Example**

```vex
plot(median(close, 20))
```

### dev

```vex
dev(x, n)
```

Mean absolute deviation of x from its n-bar average.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.dev(source, length)`

**Example**

```vex
plot(dev(close, 20))
```

### percentrank

```vex
percentrank(x, n)
```

Percent of the previous n values of x at or below this one (0 to 100).

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.percentrank(source, length)`

**Example**

```vex
plot(percentrank(volume, 100))
```

### linreg

```vex
linreg(x, n)
```

Linear regression: the least-squares line through the last n values of x, at this bar.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.linreg(source, length, 0)`

**Example**

```vex
plot(linreg(close, 50))
```

### correlation

```vex
correlation(a, b, n)
```

Correlation of a and b over the last n bars (-1 to 1).

**Arguments**

- `a`: a number per bar
- `b`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.correlation(source1, source2, length)`

**Example**

```vex
plot(correlation(close, volume, 50))
```

### loop_score

```vex
loop_score(x, from, to)
```

The for-loop score: for each bar back from `from` to `to`, +1 if x is above it now, -1 if not (or if either is empty).

For each bar back from `from` to `to`: +1 when x is above that bar's value now, -1 when it isn't (or either is empty). It is the for-loop many Pine trend scores use, done without a loop.

**Arguments**

- `x`: a number per bar
- `from`: a whole number, 0 to 5000, fixed: a number or a setting
- `to`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `for i = from to to: score += x > x[i] ? 1 : -1`

**Example**

```vex
plot(loop_score(rsi(close, 14), 1, 45))
```

See also: [Your own functions](/documentation/vex/your-own-functions)

### prev

```vex
prev(x, n = 1)
```

x as it was n bars ago (empty before the first bar, unless x has a starts line).

**Arguments**

- `x`: a number per bar
- `n`: a whole number, 0 to 5000, fixed: a number or a setting; 1 when left out

**Returns:** a number per bar

**In Pine Script:** `source[n]`

**Example**

```vex
plot(close - prev(close), "Change")
plot(close - prev(close, 10), "10-bar change")
```

See also: [Looking back: prev](/documentation/vex/looking-back-prev), [Values that carry over: starts](/documentation/vex/values-that-carry-over-starts)

## Indicators

### rsi

```vex
rsi(x, n)
```

Wilder's relative strength index, 0 to 100.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.rsi(source, length)`

**Example**

```vex
r = rsi(close, 14)
plot(r, "RSI")
level(70, 30)
```

### atr

```vex
atr(n)
```

Average true range over n bars (Wilder smoothing).

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.atr(length)`

**Example**

```vex
plot(atr(14))
```

See also: [tr](/documentation/vex/reference/bar-values#tr), [keltner](/documentation/vex/reference/indicators#keltner)

### cci

```vex
cci(n)
```

Commodity channel index on hlc3.

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.cci(hlc3, length)`

**Example**

```vex
plot(cci(20))
```

### mfi

```vex
mfi(n)
```

Money flow index on hlc3 and volume, 0 to 100.

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `ta.mfi(hlc3, length)`

**Example**

```vex
plot(mfi(14))
```

### bands

```vex
bands(x, n, mult = 2)
```

Bollinger bands: the SMA, and mult standard deviations above and below.

Pine's ta.bb gives [middle, upper, lower]; here they are .mid, .upper and .lower.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting
- `mult`: a number per bar; 2 when left out

**Returns:** several parts: .upper .mid .lower

**In Pine Script:** `ta.bb(source, length, mult)`

**Example**

```vex
name("Bollinger", where = chart)

b = bands(close, 20, 2)
plot(b.upper, "Upper")
plot(b.mid, "Middle")
plot(b.lower, "Lower")
fill(b.upper, b.lower)
```

### macd

```vex
macd(x, fast = 12, slow = 26, signal = 9)
```

MACD: fast EMA minus slow EMA, its EMA signal, and the gap between them.

**Arguments**

- `x`: a number per bar
- `fast`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 12 when left out
- `slow`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 26 when left out
- `signal`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 9 when left out

**Returns:** several parts: .line .signal .hist

**In Pine Script:** `ta.macd(source, fast, slow, signal)`

**Example**

```vex
m = macd(close, 12, 26, 9)
plot(m.hist, "Histogram", style = bars, color = m.hist > 0 ? up : down)
plot(m.line, "MACD", color = blue)
plot(m.signal, "Signal", color = orange)
level(0)
```

### stoch

```vex
stoch(n = 14, ksmooth = 1, dsmooth = 3)
```

Stochastic: where the close sits in the n-bar range (0 to 100), smoothed, and its average.

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 14 when left out
- `ksmooth`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 1 when left out
- `dsmooth`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 3 when left out

**Returns:** several parts: .k .d

**In Pine Script:** `ta.sma(ta.stoch(close, high, low, n), ksmooth)`

**Example**

```vex
s = stoch(14, 1, 3)
plot(s.k, "%K")
plot(s.d, "%D")
level(80, 20)
```

### donchian

```vex
donchian(n = 20)
```

Donchian channel: the highest high and lowest low of the last n bars, and their middle.

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 20 when left out

**Returns:** several parts: .upper .mid .lower

**Example**

```vex
d = donchian(20)
plot(d.upper, "upper")
plot(d.mid, "mid")
plot(d.lower, "lower")
```

### pivot_high

```vex
pivot_high(x, left = 5, right = 5)
```

A pivot high: x of the bar `right` bars back when it is higher than the `left` bars before it and the `right` bars after it; empty elsewhere. It is given on the bar that confirms it (`right` bars later); plot it with offset = -right to draw it on the pivot bar.

Like Pine's, the value comes on the bar that confirms the pivot, `right` bars after it, so it never repaints. `offset = -right` draws it on the pivot bar itself.

**Arguments**

- `x`: a number per bar
- `left`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 5 when left out
- `right`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 5 when left out

**Returns:** a number per bar

**In Pine Script:** `ta.pivothigh(source, leftbars, rightbars)`

**Example**

```vex
name("Pivots", where = chart)

ph = pivot_high(high, 5, 5)
pl = pivot_low(low, 5, 5)
plot(ph, "Pivot high", style = dots, width = 3, color = red, offset = -5)
plot(pl, "Pivot low", style = dots, width = 3, color = green, offset = -5)
```

See also: [pivot_low](/documentation/vex/reference/indicators#pivot-low), [plot](/documentation/vex/reference/drawing#plot)

### pivot_low

```vex
pivot_low(x, left = 5, right = 5)
```

A pivot low: x of the bar `right` bars back when it is lower than the `left` bars before it and the `right` bars after it; empty elsewhere. Given on the bar that confirms it.

**Arguments**

- `x`: a number per bar
- `left`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 5 when left out
- `right`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 5 when left out

**Returns:** a number per bar

**In Pine Script:** `ta.pivotlow(source, leftbars, rightbars)`

**Example**

```vex
name("Pivot lows", where = chart)

pl = pivot_low(low, 5, 5)
plot(pl, "Pivot low", style = dots, width = 3, color = green, offset = -5)
plot(when(not empty(pl), pl), "Last pivot low", style = steps, color = grey)
```

See also: [pivot_high](/documentation/vex/reference/indicators#pivot-high), [when](/documentation/vex/reference/events#when)

### ichimoku

```vex
ichimoku(conversion = 9, base = 26, span_b = 52)
```

Ichimoku: the conversion and base lines (the middle of the n-bar high-low range) and the leading spans as worked out on each bar. Draw the spans 25 bars ahead with offset = 25, and the lagging line as plot(close, offset = -25).

The spans are worked out on each bar and drawn 25 bars ahead with `offset = 25` (a displacement of 26 less one); the lagging line is the close drawn 25 bars back.

**Arguments**

- `conversion`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 9 when left out
- `base`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 26 when left out
- `span_b`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 52 when left out

**Returns:** several parts: .conversion .base .span_a .span_b

**Example**

```vex
name("Ichimoku", where = chart)

ich = ichimoku(9, 26, 52)
plot(ich.conversion, "Conversion", color = blue)
plot(ich.base, "Base", color = maroon)
plot(ich.span_a, "Span A", color = green, offset = 25)
plot(ich.span_b, "Span B", color = red, offset = 25)
fill(ich.span_a, ich.span_b, opacity = 15)
plot(close, "Lagging", color = teal, offset = -25)
```

See also: [plot](/documentation/vex/reference/drawing#plot), [fill](/documentation/vex/reference/drawing#fill), [donchian](/documentation/vex/reference/indicators#donchian)

### keltner

```vex
keltner(x, n = 20, atr_n = 10, mult = 2)
```

Keltner channel: an EMA, and mult ATRs above and below it.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 20 when left out
- `atr_n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 10 when left out
- `mult`: a number per bar; 2 when left out

**Returns:** several parts: .upper .mid .lower

**Example**

```vex
k = keltner(close, 20, 10, 2)
plot(k.upper, "upper")
plot(k.mid, "mid")
plot(k.lower, "lower")
```

### williams_r

```vex
williams_r(n = 14)
```

Williams %R: where the close sits in the n-bar range, -100 at the low to 0 at the high.

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 14 when left out

**Returns:** a number per bar

**In Pine Script:** `ta.wpr(length)`

**Example**

```vex
plot(williams_r(14))
```

### stochrsi

```vex
stochrsi(x, rsi_n = 14, stoch_n = 14, ksmooth = 3, dsmooth = 3)
```

Stochastic RSI: the stochastic of the RSI, smoothed, and its average.

**Arguments**

- `x`: a number per bar
- `rsi_n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 14 when left out
- `stoch_n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 14 when left out
- `ksmooth`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 3 when left out
- `dsmooth`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 3 when left out

**Returns:** several parts: .k .d

**Example**

```vex
s = stochrsi(close, 14, 14, 3, 3)
plot(s.k, "k")
plot(s.d, "d")
```

### cmf

```vex
cmf(n = 20)
```

Chaikin money flow: where closes sit in their bars, weighted by volume, over n bars (-1 to 1).

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 20 when left out

**Returns:** a number per bar

**Example**

```vex
plot(cmf(20))
```

### dmi

```vex
dmi(n = 14, smooth = 14)
```

Directional movement: +DI, -DI and the ADX trend strength.

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 14 when left out
- `smooth`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 14 when left out

**Returns:** several parts: .plus .minus .adx

**In Pine Script:** `ta.dmi(diLength, adxSmoothing)`

**Example**

```vex
m = dmi(14, 14)
plot(m.plus, "+DI", color = green)
plot(m.minus, "-DI", color = red)
plot(m.adx, "ADX", color = blue)
```

### supertrend

```vex
supertrend(n = 10, factor = 3)
```

Supertrend on hl2: a trailing line under the price in an up trend (dir 1), over it in a down trend (dir -1).

Pine's arguments are the other way round (factor first), and its direction is -1 in an up trend; here `.dir` is 1 up and -1 down.

**Arguments**

- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting; 10 when left out
- `factor`: a number fixed when the script runs: a number or a setting; 3 when left out

**Returns:** several parts: .line .dir

**In Pine Script:** `ta.supertrend(factor, atrPeriod)`

**Example**

```vex
name("Supertrend", where = chart)

st = supertrend(10, 3)
plot(st.line, "Supertrend", color = st.dir > 0 ? up : down)
```

### psar

```vex
psar(start = 0.02, inc = 0.02, max = 0.2)
```

Parabolic SAR: a stop that accelerates with the trend; dir 1 when it sits under the price.

**Arguments**

- `start`: a number fixed when the script runs: a number or a setting; 0.02 when left out
- `inc`: a number fixed when the script runs: a number or a setting; 0.02 when left out
- `max`: a number fixed when the script runs: a number or a setting; 0.2 when left out

**Returns:** several parts: .value .dir

**In Pine Script:** `ta.sar(start, inc, max)`

**Example**

```vex
name("SAR", where = chart)

sar = psar(0.02, 0.02, 0.2)
plot(sar.value, "SAR", style = dots, color = sar.dir > 0 ? up : down)
```

## Events

### crosses_above

```vex
crosses_above(a, b)
```

True on the bar a goes from at or below b to above it.

**Arguments**

- `a`: a number per bar
- `b`: a number per bar

**Returns:** a yes/no per bar

**In Pine Script:** `ta.crossover(a, b)`

**Example**

```vex
fast = ema(close, 9)
slow = ema(close, 21)
plot(fast)
plot(slow)
mark(crosses_above(fast, slow), "B", where = below)
```

See also: [crosses_below](/documentation/vex/reference/events#crosses-below), [Marks, finished bars and alerts](/documentation/vex/marks-finished-bars-and-alerts)

### crosses_below

```vex
crosses_below(a, b)
```

True on the bar a goes from at or above b to below it.

**Arguments**

- `a`: a number per bar
- `b`: a number per bar

**Returns:** a yes/no per bar

**In Pine Script:** `ta.crossunder(a, b)`

**Example**

```vex
fast = ema(close, 9)
slow = ema(close, 21)
plot(fast)
plot(slow)
mark(crosses_below(fast, slow), "S", where = above)
```

See also: [crosses_above](/documentation/vex/reference/events#crosses-above), [Marks, finished bars and alerts](/documentation/vex/marks-finished-bars-and-alerts)

### rising

```vex
rising(x, n)
```

True when x is above every value of the last n bars before it.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a yes/no per bar

**In Pine Script:** `ta.rising(source, length)`

**Example**

```vex
plot(close)
mark(rising(close, 3), where = below, shape = dot)
```

### falling

```vex
falling(x, n)
```

True when x is below every value of the last n bars before it.

**Arguments**

- `x`: a number per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a yes/no per bar

**In Pine Script:** `ta.falling(source, length)`

**Example**

```vex
plot(close)
mark(falling(close, 3), where = above, shape = dot)
```

### count

```vex
count(cond, n)
```

How many of the last n bars cond was true on.

**Arguments**

- `cond`: a yes/no per bar
- `n`: a whole number of bars, 1 to 5000, fixed: a number or a setting

**Returns:** a number per bar

**In Pine Script:** `math.sum(cond ? 1 : 0, length)`

**Example**

```vex
plot(count(close > open, 10), "Up bars of the last 10")
```

### bars_since

```vex
bars_since(cond)
```

Bars since cond was last true (0 on a bar where it is true; empty before it ever was).

**Arguments**

- `cond`: a yes/no per bar

**Returns:** a number per bar

**In Pine Script:** `ta.barssince(condition)`

**Example**

```vex
plot(bars_since(crosses_above(close, ema(close, 20))), "Bars since the cross")
```

### when

```vex
when(cond, x, k = 0)
```

x on the most recent bar where cond was true (k = 1 for the one before that, ...).

**Arguments**

- `cond`: a yes/no per bar
- `x`: a number per bar
- `k`: a whole number, 0 to 5000, fixed: a number or a setting; 0 when left out

**Returns:** a number per bar

**In Pine Script:** `ta.valuewhen(condition, source, occurrence)`

**Example**

```vex
name("Last cross price", where = chart)

plot(when(crosses_above(close, ema(close, 20)), close), "Price at the last cross", style = steps)
```

## Other bars

### timeframe

```vex
timeframe("4h", x)
```

x worked out on another timeframe of this chart's market (1m, 2m, 5m, 15m, 30m, 1h, 2h, 4h, 1D, 1W). Each bar reads the value of the last bar of that timeframe that had closed by its own close, so history never repaints; the newest bar follows the one still forming.

**Returns:** a number per bar

**In Pine Script:** `request.security(syminfo.tickerid, "240", x)`

**Example**

```vex
name("4h EMA", where = chart)

plot(ema(close, 20), "EMA 20")
plot(timeframe("4h", ema(close, 20)), "EMA 20 on 4h", color = orange, style = steps)
```

See also: [Other timeframes and markets](/documentation/vex/other-timeframes-and-markets), [symbol](/documentation/vex/reference/other-bars#symbol)

### symbol

```vex
symbol("ETHUSDT", x, timeframe = "4h")
```

x worked out on another market's bars (its own timeframe with timeframe =), lined up with this chart's bars the same way: no lookahead. Another market is drawn in its own pane.

**Returns:** a number per bar

**In Pine Script:** `request.security("ETHUSDT", timeframe.period, x)`

**Example**

```vex
name("BTC in ETH")

eth = symbol("ETHUSDT", close)
plot(close / eth, "BTC / ETH")
```

See also: [Other timeframes and markets](/documentation/vex/other-timeframes-and-markets), [timeframe](/documentation/vex/reference/other-bars#timeframe)

## Maths

### max

```vex
max(a, b, ...)
```

The largest of the values (empty values are skipped).

**Arguments**

- `a`: a number per bar
- `b`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.max(a, b)`

**Example**

```vex
plot(max(close - open, 0))
```

### min

```vex
min(a, b, ...)
```

The smallest of the values (empty values are skipped).

**Arguments**

- `a`: a number per bar
- `b`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.min(a, b)`

**Example**

```vex
plot(min(open, close))
```

### abs

```vex
abs(x)
```

x without its sign.

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.abs(x)`

**Example**

```vex
plot(abs(close - open))
```

### sqrt

```vex
sqrt(x)
```

Square root (empty below 0).

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.sqrt(x)`

**Example**

```vex
plot(stdev(close, 20) * sqrt(365), "Scaled deviation")
```

### log

```vex
log(x)
```

Natural logarithm (empty at 0 and below).

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.log(x)`

**Example**

```vex
plot(log(close))
```

### exp

```vex
exp(x)
```

e to the power x.

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.exp(x)`

**Example**

```vex
plot(exp(roc(close, 1) / 100))
```

### round

```vex
round(x)
```

Nearest whole number.

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.round(x)`

**Example**

```vex
plot(round(rsi(close, 14)), "RSI, whole")
```

### floor

```vex
floor(x)
```

Whole number at or below x.

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.floor(x)`

**Example**

```vex
plot(floor(close / 100) * 100, "Round hundred below", style = steps)
```

### ceil

```vex
ceil(x)
```

Whole number at or above x.

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.ceil(x)`

**Example**

```vex
plot(ceil(close / 100) * 100, "Round hundred above", style = steps)
```

### sign

```vex
sign(x)
```

1 if x is above 0, -1 below, 0 at 0.

**Arguments**

- `x`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.sign(x)`

**Example**

```vex
plot(sign(change(close)))
```

### pow

```vex
pow(x, p)
```

x to the power p.

**Arguments**

- `x`: a number per bar
- `p`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `math.pow(x, p)`

**Example**

```vex
plot(pow(change(close), 2), "Squared change")
```

### clamp

```vex
clamp(x, lo, hi)
```

x kept between lo and hi.

**Arguments**

- `x`: a number per bar
- `lo`: a number per bar
- `hi`: a number per bar

**Returns:** a number per bar

**Example**

```vex
plot(clamp(rsi(close, 14), 30, 70), "RSI held to 30-70")
```

### fallback

```vex
fallback(x, y)
```

x, or y where x is empty.

**Arguments**

- `x`: a number per bar
- `y`: a number per bar

**Returns:** a number per bar

**In Pine Script:** `nz(x, y)`

**Example**

```vex
plot(fallback(prev(close), close), "Previous close")
```

See also: [Empty values](/documentation/vex/empty-values), [empty](/documentation/vex/reference/maths#empty)

### empty

```vex
empty(x)
```

True where x has no value (not enough history yet, or a division by zero).

**Arguments**

- `x`: a number per bar

**Returns:** a yes/no per bar

**In Pine Script:** `na(x)`

**Example**

```vex
r = rsi(close, 14)
plot(empty(r) ? 50 : r, "RSI, 50 until ready")
```

See also: [Empty values](/documentation/vex/empty-values), [fallback](/documentation/vex/reference/maths#fallback)

## Colors

### green

green (#22c55e)

**Returns:** a color

**Example**

```vex
plot(close, color = green, width = 2)
```

### red

red (#ef4444)

**Returns:** a color

**Example**

```vex
plot(close, color = red, width = 2)
```

### blue

blue (#3b82f6)

**Returns:** a color

**Example**

```vex
plot(close, color = blue, width = 2)
```

### orange

orange (#f97316)

**Returns:** a color

**Example**

```vex
plot(close, color = orange, width = 2)
```

### purple

purple (#a855f7)

**Returns:** a color

**Example**

```vex
plot(close, color = purple, width = 2)
```

### yellow

yellow (#eab308)

**Returns:** a color

**Example**

```vex
plot(close, color = yellow, width = 2)
```

### teal

teal (#14b8a6)

**Returns:** a color

**Example**

```vex
plot(close, color = teal, width = 2)
```

### pink

pink (#ec4899)

**Returns:** a color

**Example**

```vex
plot(close, color = pink, width = 2)
```

### grey

grey (#9ca3af)

**Returns:** a color

**Example**

```vex
plot(close, color = grey, width = 2)
```

### white

white (#e5e7eb)

**Returns:** a color

**Example**

```vex
plot(close, color = white, width = 2)
```

### aqua

aqua (#06b6d4)

**Returns:** a color

**Example**

```vex
plot(close, color = aqua, width = 2)
```

### lime

lime (#84cc16)

**Returns:** a color

**Example**

```vex
plot(close, color = lime, width = 2)
```

### fuchsia

fuchsia (#d946ef)

**Returns:** a color

**Example**

```vex
plot(close, color = fuchsia, width = 2)
```

### maroon

maroon (#991b1b)

**Returns:** a color

**Example**

```vex
plot(close, color = maroon, width = 2)
```

### navy

navy (#1e3a8a)

**Returns:** a color

**Example**

```vex
plot(close, color = navy, width = 2)
```

### olive

olive (#808000)

**Returns:** a color

**Example**

```vex
plot(close, color = olive, width = 2)
```

### silver

silver (#cbd5e1)

**Returns:** a color

**Example**

```vex
plot(close, color = silver, width = 2)
```

### black

black (#0a0a0a)

**Returns:** a color

**Example**

```vex
plot(close, color = black, width = 2)
```

### up

Your candle color for up bars.

**Returns:** a color

**Example**

```vex
plot(close, color = up, width = 2)
```

### down

Your candle color for down bars.

**Returns:** a color

**Example**

```vex
plot(close, color = down, width = 2)
```
