1.8 KiB
RMA
Relative Moving Average (RMA) with the ta.rma() function.
A Relative Moving Average adds more weight to recent data (and gives less importance to older data). This makes the RMA similar to the Exponential Moving Average, although it’s somewhat slower to respond than an EMA is.
ta.rma(source, length)
source is the series of numerical values to process. It’s the (price) data we calculate the RMA on. length is an integer with the moving average length in bars. This is the lookback period over which Pine Script calculates the average. ta.rma() returns the Relative Moving Average as a floating-point value [1] .
The RMA is obtained by dividing a stock's short-term moving average of price by its long-term moving average of price. Stocks rising in price the fastest always have the highest RMAs, and those going down in price the fastest always have the lowest RMAs.
This indicator represents the relative moving average indicator (RMA). RMA = SMA(3 x Period) - SMA(2 x Period) + SMA(1 x Period) per formula: https://www.hybrid-solutions.com/plugins/client-vtl-plugins/free/rma.html
ShortAverage = new SimpleMovingAverage(name + "_Short", period); MediumAverage = new SimpleMovingAverage(name + "_Medium", period * 2); LongAverage = new SimpleMovingAverage(name + "_Long", period * 3);
LongAverage.Current.Value - MediumAverage.Current.Value + ShortAverage.Current.Value;
rma = sma(price,period3) + sma (price,period2) - sma(price,period)
alpha = 1 / length
rma = alpha * source + (1 - alpha) * RMA[1]
pine_rma(source, length) => alpha = 1 / length sum = 0.0 sum := na(sum[1]) ? ta.sma(source, length) : alpha * source + (1 - alpha) * nz(sum[1])