Moving AveragesPine Script v6

ta.rma()

Relative Moving Average (Wilder's Smoothing)

Computes Wilder's smoothing (relative moving average, RMA): an exponential-style average with alpha = 1 / length. It is the smoothing method used inside classic indicators such as RSI and ATR.

Syntax

Syntax
ta.rma(source, length) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries of values to process.
lengthsimple intSmoothing length; alpha = 1 / length.

Returns

Exponential moving average of source with alpha = 1 / length.

Remarks

na values in the source series are ignored.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.rma")
plot(ta.rma(close, 15))

//the same on pine
pine_rma(src, length) =>
    alpha = 1/length
    sum = 0.0
    sum := na(sum[1]) ? ta.sma(src, length) : alpha * src + (1 - alpha) * nz(sum[1])
plot(pine_rma(close, 15))

Trading Applications

Foundation for RSI calculation (used internally by ta.rsi)

Smoother than EMA with less sensitivity to price spikes

Calculate Average True Range (ATR) components

Build Wilder's directional movement indicators

Frequently Asked Questions

Generate ta.rma() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.rma() and other built-in functions instantly.