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
ta.rma(source, length) → series floatArguments
| Parameter | Type | Description |
|---|---|---|
| source | series int/float | Series of values to process. |
| length | simple int | Smoothing 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
//@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.
Related Pine Script Functions
ta.sma() - Simple Moving Average
Learn how to use ta.sma() in Pine Script. Syntax, parameters, code examples, and trading applications for the Simple Moving Average function.
ta.ema() - Exponential Moving Average
Learn how to use ta.ema() in Pine Script. Syntax, parameters, code examples, and trading applications for the Exponential Moving Average function.
ta.rsi() - Relative Strength Index
Learn how to use ta.rsi() in Pine Script. Syntax, parameters, code examples for the RSI momentum oscillator.
ta.atr() - Average True Range
Learn how to use ta.atr() in Pine Script. Syntax, parameters, code examples for the Average True Range volatility indicator.
ta.hma() - Hull Moving Average
Learn how to use ta.hma() in Pine Script. Syntax, parameters, code examples for the fast, low-lag Hull Moving Average.