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

Write

Technical analysis

The ta.* namespace: averages, oscillators, bands, crosses, pivots and multi-value studies, with working recipes.

View as MarkdownOpen in ClaudeOpen in ChatGPT

ta.* holds the building blocks: more than seventy functions, from ta.sma to ta.supertrend. They all follow the bar-by-bar model, so each returns a series and handles its own warm-up (the first bars are na).

Averages#

FunctionNotes
ta.sma(src, len)Simple average
ta.ema(src, len)Exponential, reacts faster
ta.wma(src, len)Linearly weighted
ta.hma(src, len)Hull, smooth and fast
ta.rma(src, len)Wilder's smoothing, used inside RSI and ATR
ta.vwma(src, len)Volume weighted (see the note on volume below)
ta.alma(src, len, offset, sigma)Arnaud Legoux

Oscillators and volatility#

ta.rsi, ta.stoch, ta.cci, ta.mfi, ta.mom, ta.roc, ta.tsi, ta.wpr, ta.atr, ta.tr, ta.stdev, ta.dev, and more.

RunnableStochastic
1//@version=62indicator("Stochastic")3k = ta.sma(ta.stoch(close, high, low, 14), 3)4d = ta.sma(k, 3)5plot(k, "%K", color = color.new(#8b7cff, 0), linewidth = 2)6plot(d, "%D", color = color.new(#ffb547, 0))7hline(80, "Upper", color = color.gray)8hline(20, "Lower", color = color.gray)

Studies that return several values#

Some functions return a tuple. Destructure it with square brackets:

RunnableMACD
1//@version=62indicator("MACD")3[macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9)4plot(hist, "Histogram", style = plot.style_columns, color = hist >= 0 ? color.new(color.teal, 40) : color.new(color.red, 40))5plot(macdLine, "MACD", color = color.new(#8b7cff, 0))6plot(signalLine, "Signal", color = color.new(#ffb547, 0))

Others in this family: ta.bb (basis, upper, lower), ta.kc (Keltner), ta.dmi (+DI, -DI, ADX), ta.supertrend (value, direction).

RunnableSupertrend
1//@version=62indicator("Supertrend", overlay = true)3[st, dir] = ta.supertrend(3, 10)4plot(dir < 0 ? st : na, "Up trend", color = color.teal, style = plot.style_linebr, linewidth = 2)5plot(dir > 0 ? st : na, "Down trend", color = color.red, style = plot.style_linebr, linewidth = 2)

In ta.supertrend, a negative direction means an up trend.

Crosses, highs and lows, pivots#

  • ta.crossover(a, b), ta.crossunder(a, b), ta.cross(a, b): true on the bar the cross happens.
  • ta.highest(src, len), ta.lowest(src, len), and ta.highestbars / ta.lowestbars for how many bars ago.
  • ta.pivothigh(src, left, right) and ta.pivotlow(...): the pivot price, reported right bars after the pivot (because it needs those bars to confirm). na elsewhere.
  • ta.valuewhen(cond, src, n): the value of src the n-th last time cond was true.
  • ta.barssince(cond): bars since cond was last true.
RunnablePivot levels
1//@version=62indicator("Pivot levels", overlay = true)3ph = ta.pivothigh(high, 10, 10)4pl = ta.pivotlow(low, 10, 10)5plot(ta.valuewhen(not na(ph), ph, 0), "Last pivot high", color = color.red, style = plot.style_stepline)6plot(ta.valuewhen(not na(pl), pl, 0), "Last pivot low", color = color.teal, style = plot.style_stepline)7plotshape(not na(ph), "PH", style = shape.triangledown, location = location.abovebar, color = color.red, offset = -10, size = size.tiny)8plotshape(not na(pl), "PL", style = shape.triangleup, location = location.belowbar, color = color.teal, offset = -10, size = size.tiny)

offset = -10 draws each marker back on the bar that actually was the pivot.

A note on volume#

Volume on this feed is a tick count per bar, not traded size. Indicators that compare volume between bars (ta.obv, ta.mfi, plotting volume itself) are meaningful on it. Ones that treat it as size, such as ta.vwap and accumulation/distribution, still compute, and the editor warns that the result is approximate. See The data.

PreviousInputsNext Drawings and tables

On this page

  • Averages
  • Oscillators and volatility
  • Studies that return several values
  • Crosses, highs and lows, pivots
  • A note on volume

Use with AI

View as MarkdownOpen in ClaudeOpen in ChatGPT