Reference: Indicators

Vex reference: indicators.

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

NameWhat
rsiWilder's relative strength index, 0 to 100.
atrAverage true range over n bars (Wilder smoothing).
cciCommodity channel index on hlc3.
mfiMoney flow index on hlc3 and volume, 0 to 100.
bandsBollinger bands: the SMA, and mult standard deviations above and below.
macdMACD: fast EMA minus slow EMA, its EMA signal, and the gap between them.
stochStochastic: where the close sits in the n-bar range (0 to 100), smoothed, and its average.
donchianDonchian channel: the highest high and lowest low of the last n bars, and their middle.
pivot_highA 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.
pivot_lowA 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.
ichimokuIchimoku: 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).
keltnerKeltner channel: an EMA, and mult ATRs above and below it.
williams_rWilliams %R: where the close sits in the n-bar range, -100 at the low to 0 at the high.
stochrsiStochastic RSI: the stochastic of the RSI, smoothed, and its average.
cmfChaikin money flow: where closes sit in their bars, weighted by volume, over n bars (-1 to 1).
dmiDirectional movement: +DI, -DI and the ADX trend strength.
supertrendSupertrend on hl2: a trailing line under the price in an up trend (dir 1), over it in a down trend (dir -1).
psarParabolic SAR: a stop that accelerates with the trend; dir 1 when it sits under the price.

rsi

1rsi(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

1r = rsi(close, 14)2plot(r, "RSI")3level(70, 30)

atr

1atr(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

1plot(atr(14))

See also: tr, keltner

cci

1cci(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

1plot(cci(20))

mfi

1mfi(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

1plot(mfi(14))

bands

1bands(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

1name("Bollinger", where = chart)2 3b = bands(close, 20, 2)4plot(b.upper, "Upper")5plot(b.mid, "Middle")6plot(b.lower, "Lower")7fill(b.upper, b.lower)

macd

1macd(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

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

stoch

1stoch(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

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

donchian

1donchian(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

1d = donchian(20)2plot(d.upper, "upper")3plot(d.mid, "mid")4plot(d.lower, "lower")

pivot_high

1pivot_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

1name("Pivots", where = chart)2 3ph = pivot_high(high, 5, 5)4pl = pivot_low(low, 5, 5)5plot(ph, "Pivot high", style = dots, width = 3, color = red, offset = -5)6plot(pl, "Pivot low", style = dots, width = 3, color = green, offset = -5)

See also: pivot_low, plot

pivot_low

1pivot_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

1name("Pivot lows", where = chart)2 3pl = pivot_low(low, 5, 5)4plot(pl, "Pivot low", style = dots, width = 3, color = green, offset = -5)5plot(when(not empty(pl), pl), "Last pivot low", style = steps, color = grey)

See also: pivot_high, when

ichimoku

1ichimoku(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

1name("Ichimoku", where = chart)2 3ich = ichimoku(9, 26, 52)4plot(ich.conversion, "Conversion", color = blue)5plot(ich.base, "Base", color = maroon)6plot(ich.span_a, "Span A", color = green, offset = 25)7plot(ich.span_b, "Span B", color = red, offset = 25)8fill(ich.span_a, ich.span_b, opacity = 15)9plot(close, "Lagging", color = teal, offset = -25)

See also: plot, fill, donchian

keltner

1keltner(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

1k = keltner(close, 20, 10, 2)2plot(k.upper, "upper")3plot(k.mid, "mid")4plot(k.lower, "lower")

williams_r

1williams_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

1plot(williams_r(14))

stochrsi

1stochrsi(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

1s = stochrsi(close, 14, 14, 3, 3)2plot(s.k, "k")3plot(s.d, "d")

cmf

1cmf(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

1plot(cmf(20))

dmi

1dmi(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

1m = dmi(14, 14)2plot(m.plus, "+DI", color = green)3plot(m.minus, "-DI", color = red)4plot(m.adx, "ADX", color = blue)

supertrend

1supertrend(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

1name("Supertrend", where = chart)2 3st = supertrend(10, 3)4plot(st.line, "Supertrend", color = st.dir > 0 ? up : down)

psar

1psar(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

1name("SAR", where = chart)2 3sar = psar(0.02, 0.02, 0.2)4plot(sar.value, "SAR", style = dots, color = sar.dir > 0 ? up : down)