ta.* reference

61 technical functions. Each is also callable bare — ema(close, 12) is the same as ta.ema(close, 12). Every example runs; click Run in terminal to try it live.

Moving averages

Smoothers over an arbitrary series.

ta.sma

ta.sma(source, length) → series

Simple moving average — the mean of the last `length` values.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.sma(close, 20), title: "SMA 20")

ta.ema

ta.ema(source, length) → series

Exponential moving average — weights recent bars more heavily.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.ema(close, 21), title: "EMA 21")

ta.wma

ta.wma(source, length) → series

Weighted moving average — linearly increasing weights toward the newest bar.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.wma(close, 20), title: "WMA 20")

ta.rma

ta.rma(source, length) → series

Wilder’s smoothing (running MA) — the basis of RSI, ATR and ADX.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.rma(close, 14), title: "RMA 14")

ta.hma

ta.hma(source, length) → series

Hull moving average — very low lag, smooth response.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.hma(close, 21), title: "HMA 21")

ta.dema

ta.dema(source, length) → series

Double exponential moving average — reduced lag vs a plain EMA.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.dema(close, 21), title: "DEMA 21")

ta.tema

ta.tema(source, length) → series

Triple exponential moving average — even less lag than DEMA.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.tema(close, 21), title: "TEMA 21")

ta.vwma

ta.vwma(source, length) → series

Volume-weighted moving average — weights each bar by its volume.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 20).

Returns: series

PulseScript
pulse 1
draw line(ta.vwma(close, 20), title: "VWMA 20")

ta.linreg

ta.linreg(source, length, offset?) → series

Linear-regression curve — the endpoint of a least-squares line over the window.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).
offsetnumber?Bars back from the endpoint (default 0).

Returns: series

PulseScript
pulse 1
draw line(ta.linreg(close, 20), title: "LinReg 20")

ta.alma

ta.alma(source, length, offset?, sigma?) → series

Arnaud Legoux MA — Gaussian-weighted; `offset` shifts phase, `sigma` sets smoothness.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 9).
offsetnumber?Phase 0–1 (default 0.85).
sigmanumber?Smoothness (default 6).

Returns: series

PulseScript
pulse 1
draw line(ta.alma(close, 9, 0.85, 6), title: "ALMA")

ta.swma

ta.swma(source) → series

Symmetrically-weighted moving average over a fixed 4-bar window (1/6, 2/6, 2/6, 1/6).

sourceseriesInput series, e.g. `close`.

Returns: series

PulseScript
pulse 1
draw line(ta.swma(close), title: "SWMA")

Oscillators & statistics

Momentum, dispersion, and rolling stats.

ta.rsi

ta.rsi(source, length) → series (0–100)

Relative Strength Index — momentum oscillator; >70 overbought, <30 oversold.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series (0–100)

PulseScript
pulse 1
meta(name: "RSI", overlay: false)
draw line(ta.rsi(close, 14), title: "RSI")

ta.stdev

ta.stdev(source, length) → series

Rolling standard deviation of the series.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.stdev(close, 20), title: "StdDev")

ta.variance

ta.variance(source, length) → series

Rolling variance (standard deviation squared).

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.variance(close, 20), title: "Variance")

ta.dev

ta.dev(source, length) → series

Rolling mean absolute deviation from the window mean.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.dev(close, 20), title: "Mean Abs Dev")

ta.median

ta.median(source, length) → series

Rolling median of the series.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.median(close, 20), title: "Median")

ta.percentRank

ta.percentRank(source, length) → series (0–100)

Percent of prior bars in the window at or below the current value.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series (0–100)

PulseScript
pulse 1
meta(name: "PctRank", overlay: false)
draw line(ta.percentRank(close, 50), title: "Percent Rank")

ta.cmo

ta.cmo(source, length) → series (-100–100)

Chande Momentum Oscillator — up/down sums, un-smoothed.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 9).

Returns: series (-100–100)

PulseScript
pulse 1
meta(name: "CMO", overlay: false)
draw line(ta.cmo(close, 9), title: "CMO")

ta.tsi

ta.tsi(source, short?, long?) → series

True Strength Index — double-EMA-smoothed momentum, ×100.

sourceseriesInput series, e.g. `close`.
shortnumber?Short smoothing (default 13).
longnumber?Long smoothing (default 25).

Returns: series

PulseScript
pulse 1
meta(name: "TSI", overlay: false)
draw line(ta.tsi(close, 13, 25), title: "TSI")

ta.roc

ta.roc(source, length) → series (%)

Rate of change — percent change over `length` bars.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 10).

Returns: series (%)

PulseScript
pulse 1
meta(name: "ROC", overlay: false)
draw line(ta.roc(close, 10), title: "ROC")

ta.mom

ta.mom(source, length) → series

Momentum — the raw difference `source − source[length]`.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 10).

Returns: series

PulseScript
pulse 1
meta(name: "Momentum", overlay: false)
draw line(ta.mom(close, 10), title: "Mom")

ta.cog

ta.cog(source, length) → series

Center of Gravity (Ehlers) — a smoothed, low-lag oscillator.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 9).

Returns: series

PulseScript
pulse 1
meta(name: "CoG", overlay: false)
draw line(ta.cog(close, 10), title: "CoG")

ta.change

ta.change(source, length?) → series

Difference between the current value and `length` bars ago (default 1).

sourceseriesInput series, e.g. `close`.
lengthnumber?Bars back (default 1).

Returns: series

PulseScript
pulse 1
draw hist(ta.change(close), title: "bar-to-bar change")

ta.cum

ta.cum(source) → series

Cumulative running sum of the series from the first bar.

sourceseriesInput series, e.g. `close`.

Returns: series

PulseScript
pulse 1
meta(name: "Cumulative", overlay: false)
draw line(ta.cum(ta.change(close)), title: "cum change")

ta.sum

ta.sum(source, length) → series

Rolling sum over the last `length` bars.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
meta(name: "Vol sum", overlay: false)
draw line(ta.sum(volume, 20), title: "20-bar volume")

ta.highest

ta.highest(source, length) → series

Highest value over the last `length` bars.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.highest(high, 20), title: "20-bar high")

ta.lowest

ta.lowest(source, length) → series

Lowest value over the last `length` bars.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
draw line(ta.lowest(low, 20), title: "20-bar low")

ta.sinceHighest

ta.sinceHighest(source, length) → series

Bars ago the window’s highest value occurred (0 = current bar).

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series (bars)

PulseScript
pulse 1
meta(name: "Bars since high", overlay: false)
draw line(ta.sinceHighest(high, 20), title: "bars since high")

ta.sinceLowest

ta.sinceLowest(source, length) → series

Bars ago the window’s lowest value occurred (0 = current bar).

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 14).

Returns: series (bars)

PulseScript
pulse 1
meta(name: "Bars since low", overlay: false)
draw line(ta.sinceLowest(low, 20), title: "bars since low")

ta.correlation

ta.correlation(a, b, length) → series (-1–1)

Rolling Pearson correlation between two series.

aseriesFirst series.
bseriesSecond series.
lengthnumberWindow length (default 14).

Returns: series (-1–1)

PulseScript
pulse 1
meta(name: "Corr", overlay: false)
draw line(ta.correlation(close, volume, 20), title: "price/volume corr")

Events & state

Crosses, trends, pivots, and “bars since”.

ta.rising

ta.rising(source, length) → bool

True when the series rose on each of the last `length` bars.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 1).

Returns: bool

PulseScript
pulse 1
when ta.rising(close, 3): mark note at high "3 up"

ta.falling

ta.falling(source, length) → bool

True when the series fell on each of the last `length` bars.

sourceseriesInput series, e.g. `close`.
lengthnumberWindow length (default 1).

Returns: bool

PulseScript
pulse 1
when ta.falling(close, 3): mark note at low "3 down"

ta.crossOver

ta.crossOver(a, b) → bool

True on the bar where `a` crosses above `b`.

aseriesFast series.
bseriesSlow series.

Returns: bool

PulseScript
pulse 1
when ta.crossOver(ema(close, 9), ema(close, 21)): mark buy at low "Long"

ta.crossUnder

ta.crossUnder(a, b) → bool

True on the bar where `a` crosses below `b`.

aseriesFast series.
bseriesSlow series.

Returns: bool

PulseScript
pulse 1
when ta.crossUnder(ema(close, 9), ema(close, 21)): mark sell at high "Short"

ta.cross

ta.cross(a, b) → bool

True on any bar where `a` and `b` cross (either direction).

aseriesFirst series.
bseriesSecond series.

Returns: bool

PulseScript
pulse 1
when ta.cross(ema(close, 9), ema(close, 21)): mark note at high "cross"

ta.since

ta.since(condition) → series

Bars since `condition` was last true (none before the first occurrence).

conditionbool seriesThe event to count from.

Returns: series (bars)

PulseScript
pulse 1
meta(name: "Bars since cross", overlay: false)
draw line(ta.since(ta.crossOver(ema(close, 9), ema(close, 21))), title: "bars since cross")

ta.lastWhen

ta.lastWhen(condition, source, back?) → series

Value of `source` at the `back`-th most recent bar where `condition` was true (0 = latest).

conditionbool seriesThe event.
sourceseriesValue to read.
backnumber?How many occurrences back (default 0).

Returns: series

PulseScript
pulse 1
draw line(ta.lastWhen(ta.crossOver(ema(close, 9), ema(close, 21)), close, 0), title: "price at last cross")

ta.hold

ta.hold(source) → series

Carry the last finite value forward (fills gaps / none values).

sourceseriesPossibly-gappy series.

Returns: series

PulseScript
pulse 1
draw line(ta.hold(ta.pivotHigh(high, 5, 5)), title: "last pivot high held")

ta.pivotHigh

ta.pivotHigh(source, left, right) → series

Confirmed swing high — a bar above its `left`/`right` neighbours; appears on the confirmation bar (no repaint).

sourceseriesUsually `high`.
leftnumberBars to the left (default 5).
rightnumberBars to the right (default 5).

Returns: series (pivot price)

PulseScript
pulse 1
draw dots(ta.pivotHigh(high, 5, 5), color: "#ef4444", title: "pivot high")

ta.pivotLow

ta.pivotLow(source, left, right) → series

Confirmed swing low — a bar below its `left`/`right` neighbours; appears on the confirmation bar (no repaint).

sourceseriesUsually `low`.
leftnumberBars to the left (default 5).
rightnumberBars to the right (default 5).

Returns: series (pivot price)

PulseScript
pulse 1
draw dots(ta.pivotLow(low, 5, 5), color: "#22c55e", title: "pivot low")

Candle studies

Read OHLCV directly (ATR, VWAP, CCI, …).

ta.atr

ta.atr(length) → series

Average True Range — Wilder-smoothed volatility.

lengthnumberWindow length (default 14).

Returns: series

PulseScript
pulse 1
meta(name: "ATR", overlay: false)
draw line(ta.atr(14), title: "ATR 14")

ta.tr

ta.tr() → series

True Range of each bar (before smoothing).

Returns: series

PulseScript
pulse 1
meta(name: "True Range", overlay: false)
draw line(ta.tr(), title: "TR")

ta.vwap

ta.vwap() → series

Volume-Weighted Average Price for the session.

Returns: series

PulseScript
pulse 1
draw line(ta.vwap(), color: "#f59e0b", title: "VWAP")

ta.cci

ta.cci(length) → series

Commodity Channel Index — deviation of typical price from its average.

lengthnumberWindow length (default 20).

Returns: series

PulseScript
pulse 1
meta(name: "CCI", overlay: false)
draw line(ta.cci(20), title: "CCI 20")

ta.mfi

ta.mfi(length) → series (0–100)

Money Flow Index — volume-weighted RSI.

lengthnumberWindow length (default 14).

Returns: series (0–100)

PulseScript
pulse 1
meta(name: "MFI", overlay: false)
draw line(ta.mfi(14), title: "MFI 14")

ta.willr

ta.willr(length) → series (-100–0)

Williams %R — where the close sits in the recent high/low range.

lengthnumberWindow length (default 14).

Returns: series (-100–0)

PulseScript
pulse 1
meta(name: "Williams %R", overlay: false)
draw line(ta.willr(14), title: "%R")

ta.obv

ta.obv() → series

On-Balance Volume — cumulative volume signed by price direction.

Returns: series

PulseScript
pulse 1
meta(name: "OBV", overlay: false)
draw line(ta.obv(), title: "OBV")

ta.cmf

ta.cmf(length) → series (-1–1)

Chaikin Money Flow — buying/selling pressure over the window.

lengthnumberWindow length (default 20).

Returns: series (-1–1)

PulseScript
pulse 1
meta(name: "CMF", overlay: false)
draw line(ta.cmf(20), title: "CMF 20")

ta.rvol

ta.rvol(length) → series

Relative volume — current volume vs its `length`-bar average (2 = twice normal).

lengthnumberWindow length (default 20).

Returns: series

PulseScript
pulse 1
meta(name: "RVOL", overlay: false)
draw line(ta.rvol(20), title: "RVOL")

ta.sar

ta.sar(start?, step?, max?) → series

Parabolic SAR — trailing stop-and-reverse dots.

startnumber?Initial acceleration (default 0.02).
stepnumber?Acceleration step (default 0.02).
maxnumber?Max acceleration (default 0.2).

Returns: series

PulseScript
pulse 1
draw dots(ta.sar(0.02, 0.02, 0.2), color: "#a78bfa", title: "SAR")

ta.macd

ta.macd(fast?, slow?, signal?) → series

MACD line (fast EMA − slow EMA). For all three lines use `ta.macdFull`.

fastnumber?Fast EMA (default 12).
slownumber?Slow EMA (default 26).
signalnumber?Signal EMA (default 9).

Returns: series

PulseScript
pulse 1
meta(name: "MACD line", overlay: false)
draw line(ta.macd(12, 26, 9), title: "MACD")

ta.stoch

ta.stoch(kLength?, kSmooth?, dSmooth?) → series (0–100)

Stochastic %K line. For %K and %D use `ta.stochFull`.

kLengthnumber?%K lookback (default 14).
kSmoothnumber?%K smoothing (default 3).
dSmoothnumber?%D smoothing (default 3).

Returns: series (0–100)

PulseScript
pulse 1
meta(name: "Stoch", overlay: false)
draw line(ta.stoch(14, 3, 3), title: "%K")

Multi-output studies

Return a record — access fields like ta.bands(20, 2).upper.

ta.macdFull

ta.macdFull(fast?, slow?, signal?) → record { line, signal, histo }

Full MACD — the MACD line, its signal EMA, and the histogram.

fastnumber?Fast EMA (default 12).
slownumber?Slow EMA (default 26).
signalnumber?Signal EMA (default 9).

Returns: record { line, signal, histo }

PulseScript
pulse 1
meta(name: "MACD", overlay: false)
m = ta.macdFull(12, 26, 9)
draw line(m.line, color: "#38bdf8", title: "MACD")
draw line(m.signal, color: "#f59e0b", title: "signal")
draw hist(m.histo, title: "histogram")

ta.stochFull

ta.stochFull(kLength?, kSmooth?, dSmooth?) → record { k, d }

Full Stochastic — the %K and %D lines.

kLengthnumber?%K lookback (default 14).
kSmoothnumber?%K smoothing (default 3).
dSmoothnumber?%D smoothing (default 3).

Returns: record { k, d }

PulseScript
pulse 1
meta(name: "Stoch", overlay: false)
s = ta.stochFull(14, 3, 3)
draw line(s.k, color: "#38bdf8", title: "%K")
draw line(s.d, color: "#f59e0b", title: "%D")

ta.bands

ta.bands(length?, mult?) → record { upper, mid, lower, width, pctB }

Bollinger Bands — SMA basis ± `mult` standard deviations, plus width and %B.

lengthnumberWindow length (default 20).
multnumber?StdDev multiplier (default 2).

Returns: record { upper, mid, lower, width, pctB }

PulseScript
pulse 1
b = ta.bands(20, 2)
draw band(b.upper, b.lower, color: "rgba(124,156,255,0.15)", title: "BB")
draw line(b.mid, color: "#7c9cff", title: "basis")

ta.channel

ta.channel(emaLen?, atrLen?, mult?) → record { upper, mid, lower }

Keltner Channel — EMA basis ± `mult` × ATR.

emaLennumber?Basis EMA (default 20).
atrLennumber?ATR length (default 10).
multnumber?ATR multiplier (default 2).

Returns: record { upper, mid, lower }

PulseScript
pulse 1
k = ta.channel(20, 10, 2)
draw band(k.upper, k.lower, color: "rgba(34,197,94,0.12)", title: "Keltner")

ta.donchian

ta.donchian(length?) → record { upper, mid, lower }

Donchian Channel — highest high and lowest low over the window.

lengthnumberWindow length (default 20).

Returns: record { upper, mid, lower }

PulseScript
pulse 1
d = ta.donchian(20)
draw band(d.upper, d.lower, color: "rgba(245,158,11,0.12)", title: "Donchian")

ta.dmi

ta.dmi(length?) → record { plus, minus, adx }

Directional Movement — +DI, −DI and the ADX trend-strength line.

lengthnumberWindow length (default 14).

Returns: record { plus, minus, adx }

PulseScript
pulse 1
meta(name: "DMI", overlay: false)
d = ta.dmi(14)
draw line(d.plus, color: "#22c55e", title: "+DI")
draw line(d.minus, color: "#ef4444", title: "-DI")
draw line(d.adx, color: "#e6edf3", title: "ADX")

ta.supertrend

ta.supertrend(mult?, atrLen?) → record { line, dir }

SuperTrend — an ATR trailing stop; `dir` is +1 up-trend / −1 down-trend.

multnumber?ATR multiplier (default 3).
atrLennumber?ATR length (default 10).

Returns: record { line, dir }

PulseScript
pulse 1
st = ta.supertrend(3, 10)
draw line(st.line, color: "#a78bfa", title: "SuperTrend")
when st.dir > st.dir[1]: mark buy at low "flip up"

ta.ichimoku

ta.ichimoku(conv?, base?, spanB?) → record { conversion, base, spanA, spanB, lagging }

Ichimoku Cloud — conversion/base lines, the two span (cloud) lines, and the lagging span.

convnumber?Conversion length (default 9).
basenumber?Base length (default 26).
spanBnumber?Span B length (default 52).

Returns: record { conversion, base, spanA, spanB, lagging }

PulseScript
pulse 1
i = ta.ichimoku(9, 26, 52)
draw line(i.conversion, color: "#38bdf8", title: "Tenkan")
draw line(i.base, color: "#f59e0b", title: "Kijun")
draw band(i.spanA, i.spanB, color: "rgba(124,156,255,0.1)", title: "cloud")

ta.aroon

ta.aroon(length?) → record { up, down, osc }

Aroon — how recently the window’s high/low occurred, plus the oscillator (up − down).

lengthnumberWindow length (default 25).

Returns: record { up, down, osc }

PulseScript
pulse 1
meta(name: "Aroon", overlay: false)
a = ta.aroon(25)
draw line(a.up, color: "#22c55e", title: "up")
draw line(a.down, color: "#ef4444", title: "down")