ta.rma()Relative Moving Average (Wilder's Smoothing)
ta.rma() computes Wilder's Relative Moving Average with alpha = 1 / length. Its length must be a simple integer, and Pine uses this smoothing method inside indicators such as RSI and ATR.
Pine Script v6 reference verified: · TradingView reference
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, and the function calculates across the requested number of non-na values. The built-in length argument is a simple int, so it cannot vary from bar to bar.
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.