ta.* functions

ta.* functions

On this page

Each takes Series (or numbers) and returns a Series with full history, or an object of Series where noted. Lengths are plain numbers.

Trend

ta.sma / ema / rma / wma / hma / dema / tema (src, length)

Moving averages.

ta.vwma(src, volume, length)

Volume-weighted moving average.

ta.alma(src, period, offset?, sigma?)

Arnaud Legoux moving average.

ta.linreg(src, length)

Linear regression (least-squares) line.

ta.supertrend(high, low, close, length, factor)

Returns { value, direction }.

ta.sar(high, low, start?, step?, max?)

Parabolic SAR.

ta.adx(high, low, close, length)

Average Directional Index.

Momentum

ta.rsi(src, length)

Relative Strength Index.

ta.macd(src, fast?, slow?, signal?)

Returns { macd, signal, histogram }.

ta.stoch(high, low, close, kPeriod?, kSmooth?, dSmooth?)

Returns { k, d }.

ta.cci(src, length)

Commodity Channel Index.

ta.roc / mom / cmo (src, length)

Rate of change, momentum, Chande momentum.

ta.tsi(src, long?, short?)

True Strength Index. Returns { tsi, signal }.

ta.wpr(high, low, close, period)

Williams %R.

Volatility

ta.atr(length) or ta.atr(length, high, low, close)

Average True Range. The short form uses the chart's own high/low/close. Note the length comes first.

ta.tr(high, low, close)

True range per bar.

ta.bbands(src, length, mult?)

Bollinger Bands. Returns { upper, middle, lower }.

ta.keltner(close, high, low, length, mult?)

Keltner Channel. Returns { upper, middle, lower }.

ta.stdev / dev / variance (src, length)

Spread measures.

Volume

ta.vwap(high, low, close, volume)

Volume-weighted average price.

ta.dailyVwap(src, volume, tzOffsetHours?)

VWAP that resets each day. Returns { vwap, dev }.

ta.anchoredVwap(anchor, src, volume)

VWAP from the bars where anchor is true. Returns { vwap, dev }.

ta.obv(close, volume)

On-Balance Volume.

ta.mfi(high, low, close, volume, length)

Money Flow Index.

ta.ad(high, low, close, volume)

Accumulation/Distribution.

Signals & helpers

ta.crossover / crossunder / cross (a, b)

1 on the bar where a crosses b.

ta.highest / lowest / sum / median (src, length)

Rolling window values. highestbars / lowestbars give the offset instead.

ta.change(src, length?) · ta.rising / falling (src, length)

Bar-over-bar change and trend tests.

ta.pivotHigh / pivotLow (src, left, right)

Swing points.

ta.valueWhen(cond, src, occurrence?) · ta.barssince(cond) · ta.cum(src)

Remember values, count bars, running totals.

ta.percentRank / correlation · ta.swma · ta.cog

Statistics and smoothing.

ta.session / sessionHigh / sessionLow / newDay / hour / dayOfWeek

Time and session helpers.