Documentation Index
Fetch the complete documentation index at: https://docs.darvas.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
All moving average functions accept asource argument - either a ctx.* accessor, an input.source() result, or any (offset?) => number | null function. They return a scalar at the current bar.
Functions
ta.sma(source, length) - Simple moving average
Arithmetic mean over length bars.
ta.ema(source, length) - Exponential moving average
Exponentially weighted, with factor α = 2 / (length + 1). Faster to react than SMA.
ta.rma(source, length) - Wilder smoothing
EMA with α = 1 / length. Also known as Wilder’s Moving Average (RMA). Used internally by ta.rsi and ta.atr.
ta.wma(source, length) - Weighted moving average
Linearly weighted - most recent bar has the highest weight.
ta.hma(source, length) - Hull moving average
Reduces lag by combining WMAs. HMA = WMA(2*WMA(n/2) - WMA(n), sqrt(n)).
ta.vwma(source, volume, length) - Volume-weighted moving average
Weights each bar by its volume.
ta.alma(source, length, offset?, sigma?) - Arnaud Legoux moving average
Gaussian-weighted. offset controls the phase (default 0.85), sigma controls smoothing (default 6).
ta.swma(source) - Symmetrically weighted moving average
Fixed-length 4-bar average with weights [1, 2, 2, 1] / 6.
ta.linreg(source, length) - Linear regression value
Returns the current value on the linear regression line fitted to the last length bars.
Ribbon example
Related pages
Oscillators
RSI, MACD, Stochastic and more.
Crossovers
Detect when two MAs cross.
Bar context
Source function shape reference.