Skip to content
TradequixDocsOpen the terminal
OverviewStart here, search, progress
  • Introduction
  • Quickstart
  • How a script runs
  • Types and qualifiers
  • Operators, conditionals and loops
  • Functions and methods
  • Objects and enums
  • Arrays, matrices and maps
  • Strings and colours
  • Time and sessions
  • Bar states
  • Plotting
  • Inputs
  • Technical analysis
  • Drawings and tables
  • Multiple timeframes
  • Strategies
  • Alerts in scripts
  • Repainting
  • The Pine editor
  • Indicator settings
  • Coming from TradingView
  • The data
  • Publish and sell
  • Catalogue and community
  • Your dashboard and earnings
  • Errors and debugging
  • Limits
  • Coverage
  • Built-in catalogue
  • Cookbook
  • Write Pine with AI
  • FAQ
  • Glossary
  • Cheat sheet
  • Function reference
  • Will it run here?
  • Error index
Function reference

ta: technical analysis

Averages, oscillators, bands, trend studies, crosses, pivots and lookbacks. Each returns a series and handles its own warm-up.

67 names from PineTS 0.11.1 · 53 with full entries

ta.sma

Verified
ta.sma(source, length)

Simple moving average: the mean of the last length values.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.

Returns series float

Runnableta.sma
1//@version=62indicator("ta.sma", overlay = true)3plot(ta.sma(close, 50), "SMA 50", color = color.orange, linewidth = 2)

See alsota.emata.wma

ta.ema

Verified
ta.ema(source, length)

Exponential moving average; recent bars weigh more.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.

Returns series float

Runnableta.ema
1//@version=62indicator("ta.ema", overlay = true)3plot(ta.ema(close, 21), "EMA 21", color = color.teal, linewidth = 2)

See alsota.smata.rma

ta.wma

Verified
ta.wma(source, length)

Weighted moving average with linearly decreasing weights.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.

Returns series float

ta.hma

Verified
ta.hma(source, length)

Hull moving average: smooth with little lag.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.

Returns series float

ta.rma

Verified
ta.rma(source, length)

Wilder's moving average, the smoothing used inside RSI and ATR.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.

Returns series float

ta.vwma

Verified
ta.vwma(source, length)

Volume-weighted moving average. Volume on this feed is a tick count.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.

Returns series float

ta.alma

Verified
ta.alma(series, length, offset, sigma, floor)

Arnaud Legoux moving average: a Gaussian-weighted average.

ArgumentTypeMeaning
seriesseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.
offsetsimple float0 to 1; higher reacts faster. 0.85 is usual.
sigmasimple floatSmoothness; 6 is usual.

Returns series float

ta.swma

Supported
ta.swma(source)

Symmetrically weighted average over a fixed 4 bars.

Returns series float

ta.linreg

Verified
ta.linreg(source, length, offset)

Linear regression line's value, offset bars from the end.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.
offsetsimple int0 for the current bar.

Returns series float

ta.rsi

Verified
ta.rsi(source, length)

Relative Strength Index, 0 to 100.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intUsually 14.

Returns series float

Runnableta.rsi
1//@version=62indicator("ta.rsi")3r = ta.rsi(close, 14)4plot(r, "RSI", color = color.purple)5hline(70)6hline(30)

See alsota.stochta.mfi

ta.stoch

Verified
ta.stoch(source, high, low, length)

Stochastic %K, unsmoothed. Smooth it with ta.sma for the classic %K and %D.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
highseries floatUsually high.
lowseries floatUsually low.
lengthseries intHow many bars to look back.

Returns series float

Runnableta.stoch
1//@version=62indicator("ta.stoch")3k = ta.sma(ta.stoch(close, high, low, 14), 3)4plot(k, "%K")5plot(ta.sma(k, 3), "%D", color = color.orange)

ta.cci

Verified
ta.cci(source, length)

Commodity Channel Index.

ArgumentTypeMeaning
sourceseries floatUsually hlc3.
lengthseries intHow many bars to look back.

Returns series float

ta.mfi

Verified
ta.mfi(series, length)

Money Flow Index, RSI weighted by volume (tick count here).

ArgumentTypeMeaning
seriesseries floatUsually hlc3.
lengthseries intHow many bars to look back.

Returns series float

ta.mom

Verified
ta.mom(source, length)

Momentum: source minus source length bars ago.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.

Returns series float

ta.roc

Verified
ta.roc(source, length)

Rate of change, in percent.

ArgumentTypeMeaning
sourceseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.

Returns series float

ta.tsi

Verified
ta.tsi(source, short_length, long_length)

True Strength Index, -1 to 1.

Returns series float

ta.wpr

Verified
ta.wpr(length)

Williams %R, -100 to 0.

ArgumentTypeMeaning
lengthseries intHow many bars to look back.

Returns series float

ta.cmo

Verified
ta.cmo(series, length)

Chande Momentum Oscillator.

Returns series float

ta.atr

Verified
ta.atr(length)

Average True Range: the typical bar range, smoothed with RMA.

ArgumentTypeMeaning
lengthseries intUsually 14.

Returns series float

Runnableta.atr
1//@version=62indicator("ta.atr")3plot(ta.atr(14), "ATR 14", color = color.orange)

See alsota.tr

ta.tr

Verified
ta.tr  ·  ta.tr(handle_na)

True range of the current bar.

Returns series float

ta.stdev

Verified
ta.stdev(source, length, biased)

Standard deviation over length bars.

Returns series float

ta.dev

Supported
ta.dev(source, length)

Mean absolute deviation from the SMA.

Returns series float

ta.variance

Supported
ta.variance(source, length, biased)

Variance over length bars.

Returns series float

ta.bb

Verified
ta.bb(series, length, mult)

Bollinger Bands.

ArgumentTypeMeaning
seriesseries floatThe series to read, usually close.
lengthseries intHow many bars to look back.
multsimple floatStandard deviations; 2 is usual.

Returns [middle, upper, lower]

Runnableta.bb
1//@version=62indicator("ta.bb", overlay = true)3[m, u, l] = ta.bb(close, 20, 2)4plot(m, "Basis", color = color.orange)5plot(u, "Upper")6plot(l, "Lower")

See alsota.bbwta.kc

ta.bbw

Supported
ta.bbw(series, length, mult)

Bollinger Band width as a fraction of the basis.

Returns series float

ta.kc

Verified
ta.kc(series, length, mult, useTrueRange)

Keltner Channels around an EMA.

Returns [middle, upper, lower]

ta.kcw

Supported
ta.kcw(series, length, mult, useTrueRange)

Keltner Channel width.

Returns series float

ta.macd

Verified
ta.macd(source, fastlen, slowlen, siglen)

MACD line, signal line and histogram.

Returns [macdLine, signalLine, histLine]

Runnableta.macd
1//@version=62indicator("ta.macd")3[m, s, h] = ta.macd(close, 12, 26, 9)4plot(h, "Hist", style = plot.style_columns, color = h >= 0 ? color.teal : color.red)5plot(m, "MACD")6plot(s, "Signal", color = color.orange)

ta.dmi

Verified
ta.dmi(diLength, adxSmoothing)

Directional Movement: +DI, -DI and ADX.

Returns [plus, minus, adx]

Runnableta.dmi
1//@version=62indicator("ta.dmi")3[p, m, adx] = ta.dmi(14, 14)4plot(p, "+DI", color = color.teal)5plot(m, "-DI", color = color.red)6plot(adx, "ADX", color = color.orange)

ta.supertrend

Verified
ta.supertrend(factor, atrPeriod)

Supertrend line and direction. A negative direction is an up trend.

Returns [supertrend, direction]

Runnableta.supertrend
1//@version=62indicator("ta.supertrend", overlay = true)3[st, dir] = ta.supertrend(3, 10)4plot(st, "Supertrend", color = dir < 0 ? color.teal : color.red)

ta.sar

Verified
ta.sar(start, inc, max)

Parabolic SAR.

ArgumentTypeMeaning
startsimple float0.02 is usual.
incsimple float0.02 is usual.
maxsimple float0.2 is usual.

Returns series float

Runnableta.sar
1//@version=62indicator("ta.sar", overlay = true)3plot(ta.sar(0.02, 0.02, 0.2), "SAR", style = plot.style_cross, color = color.orange)

ta.crossover

Verified
ta.crossover(source1, source2)

true on the bar source1 moves from below source2 to above it.

Returns series bool

Runnableta.crossover
1//@version=62indicator("ta.crossover", overlay = true)3f = ta.ema(close, 9)4s = ta.ema(close, 21)5plotshape(ta.crossover(f, s), style = shape.triangleup, location = location.belowbar, color = color.teal)

See alsota.crossunderta.cross

ta.crossunder

Verified
ta.crossunder(source1, source2)

true on the bar source1 moves from above source2 to below it.

Returns series bool

ta.cross

Verified
ta.cross(source1, source2)

true on any cross, either direction.

Returns series bool

ta.highest

Verified
ta.highest(source, length)

Highest value over the last length bars, including this one.

Returns series float

Runnableta.highest
1//@version=62indicator("ta.highest", overlay = true)3plot(ta.highest(high, 20), "20-bar high", color = color.teal)4plot(ta.lowest(low, 20), "20-bar low", color = color.red)

See alsota.lowestta.highestbars

ta.lowest

Verified
ta.lowest(source, length)

Lowest value over the last length bars.

Returns series float

ta.highestbars

Verified
ta.highestbars(source, length)

Offset (0 or negative) to the highest bar in the window.

Returns series int

ta.lowestbars

Verified
ta.lowestbars(source, length)

Offset (0 or negative) to the lowest bar in the window.

Returns series int

ta.pivothigh

Verified
ta.pivothigh(source, leftbars, rightbars)  ·  ta.pivothigh(leftbars, rightbars)

The pivot's price, reported rightbars after it; na elsewhere.

Returns series float

Shift markers back with offset = -rightbars to draw them on the pivot bar.

Runnableta.pivothigh
1//@version=62indicator("ta.pivothigh", overlay = true)3ph = ta.pivothigh(high, 5, 5)4plotshape(not na(ph), style = shape.triangledown, location = location.abovebar, color = color.red, offset = -5)

See alsota.pivotlow

ta.pivotlow

Verified
ta.pivotlow(source, leftbars, rightbars)  ·  ta.pivotlow(leftbars, rightbars)

The pivot low's price, reported rightbars after it; na elsewhere.

Returns series float

ta.valuewhen

Verified
ta.valuewhen(condition, source, occurrence)

source's value on the occurrence-th most recent bar where condition was true (0 is the latest).

Returns series

Runnableta.valuewhen
1//@version=62indicator("ta.valuewhen", overlay = true)3up = ta.crossover(close, ta.sma(close, 20))4plot(ta.valuewhen(up, close, 0), "Close at last cross", style = plot.style_stepline)

ta.barssince

Supported
ta.barssince(condition)

Bars since condition was last true; na before it ever was.

Returns series int

ta.change

Verified
ta.change(source, length)

source minus source length bars ago (length defaults to 1). For bools, true when the value changed.

Returns series

ta.rising

Supported
ta.rising(source, length)

true when source has risen on each of the last length bars.

Returns series bool

ta.falling

Supported
ta.falling(source, length)

true when source has fallen on each of the last length bars.

Returns series bool

ta.cum

Supported
ta.cum(source)

Running total of source since the first bar.

Returns series float

ta.correlation

Supported
ta.correlation(source1, source2, length)

Pearson correlation of two series, -1 to 1.

Returns series float

ta.percentrank

Supported
ta.percentrank(source, length)

Percent of the last length values below the current one.

Returns series float

ta.median

Supported
ta.median(source, length)

Median over length bars.

Returns series float

ta.range

Supported
ta.range(source, length)

Highest minus lowest over length bars.

Returns series float

ta.obv

Verified
ta.obv

On Balance Volume. Meaningful on tick-count volume.

Returns series float

ta.accdist

Verified
ta.accdist

Accumulation/Distribution. Treats volume as size, so it is approximate here.

Returns series float

ta.vwap

Verified
ta.vwap(source)  ·  ta.vwap(source, anchor, stdev_mult)

Volume-weighted average price. Volume is a tick count on this feed, so treat it as approximate.

Returns series float · [vwap, upper, lower]

Everything else in ta

Also implemented. These follow TradingView’s Pine v6 reference for their arguments.

  • ta.cogSupportedCenter of Gravity (COG) The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.
  • ta.iiiSupportedIntraday Intensity Index (III) Formula (as TradingView computes it; its reference manual shows a division by volume): (2 * close - high - low) / (high - low) * volume
  • ta.maxSupportedTrailing Maximum (ta.max) Returns the all-time high value of `source` from the first bar of the chart up to the current bar.
  • ta.minSupportedTrailing Minimum (ta.min) Returns the all-time low value of `source` from the first bar of the chart up to the current bar.
  • ta.modeSupportedMode Returns the mode of the series.
  • ta.nviSupportedNegative Volume Index (NVI) Formula: If close or close[1] is 0, nvi = nvi[1] Else if volume < volume[1], nvi = nvi[1] + ((close - close[1]) / close[1]) * nvi[1] Else nvi = nvi[1] Initial value is 1.0
  • ta.percentile_linear_interpolationSupportedPercentile Linear Interpolation Calculates percentile using method of linear interpolation between the two nearest ranks.
  • ta.percentile_nearest_rankSupportedPercentile Nearest Rank Calculates percentile using method of Nearest Rank.
  • ta.pivot_point_levelsSupportedta.pivot_point_levels(type, anchor, developing) → array<float> of 11 levels [P, R1, S1, …, R5, S5].
  • ta.pviSupportedPositive Volume Index (PVI) Formula: If close or close[1] is 0, pvi = pvi[1] Else if volume > volume[1], pvi = pvi[1] + ((close - close[1]) / close[1]) * pvi[1] Else pvi = pvi[1] Initial value is 1.0
  • ta.pvtVerifiedPrice-Volume Trend (PVT) The PVT function calculates the Price-Volume Trend, which is a cumulative total of volume adjusted by the percentage change in price.
  • ta.rciSupportedRank Correlation Index: Spearman's rank correlation between the last `length` values of `source` and their bar order, scaled to -100..100 (100 = rose on every bar).
  • ta.wadSupportedWilliams Accumulation/Distribution (WAD) Formula: trueHigh = math.max(high, close[1]) trueLow = math.min(low, close[1]) mom = ta.change(close) gain = (mom > 0) ?
  • ta.wvadSupportedWilliams Variable Accumulation/Distribution (WVAD) Formula: (close - open) / (high - low) * volume

On this page

  • ta.sma
  • ta.ema
  • ta.wma
  • ta.hma
  • ta.rma
  • ta.vwma
  • ta.alma
  • ta.swma
  • ta.linreg
  • ta.rsi
  • ta.stoch
  • ta.cci
  • ta.mfi
  • ta.mom
  • ta.roc
  • ta.tsi
  • ta.wpr
  • ta.cmo
  • ta.atr
  • ta.tr
  • ta.stdev
  • ta.dev
  • ta.variance
  • ta.bb
  • ta.bbw
  • ta.kc
  • ta.kcw
  • ta.macd
  • ta.dmi
  • ta.supertrend
  • ta.sar
  • ta.crossover
  • ta.crossunder
  • ta.cross
  • ta.highest
  • ta.lowest
  • ta.highestbars
  • ta.lowestbars
  • ta.pivothigh
  • ta.pivotlow
  • ta.valuewhen
  • ta.barssince
  • ta.change
  • ta.rising
  • ta.falling
  • ta.cum
  • ta.correlation
  • ta.percentrank
  • ta.median
  • ta.range
  • ta.obv
  • ta.accdist
  • ta.vwap
  • Everything else (14)