SMMA initialization and a calculation you can check
Use N = 3 and the hypothetical values 100, 102, 104, 106, 108 and 110, in that order. SMMA has no value for the first two observations. Its first value is (100 + 102 + 104) / 3 = 102. At observation 4 it becomes 102 + (106 - 102) / 3 = 103.3333.
| Observation | Source | SMMA / RMA | SMA | Pine EMA |
|---|---|---|---|---|
| 1 | 100 | Not seeded | Not ready | 100.0000 |
| 2 | 102 | Not seeded | Not ready | 101.0000 |
| 3 | 104 | 102.0000 | 102.0000 | 102.5000 |
| 4 | 106 | 103.3333 | 104.0000 | 104.2500 |
| 5 | 108 | 104.8889 | 106.0000 | 106.1250 |
| 6 | 110 | 106.5926 | 108.0000 | 108.0625 |
The EMA column follows Pine's source-value seed: it starts at 100 and then uses alpha = 2/(3 + 1) = 0.5. SMMA uses alpha = 1/3 after its SMA seed. The SMA column averages the latest three observations. These differences explain the table; they are not a measured trading advantage. The initialization rules come from the RMA and EMA reference examples.
SMMA vs EMA vs SMA: compare the weights
| Method | New-value weight at N = 14 | What happens to old values? |
|---|---|---|
| SMMA / RMA | 1/14 = 7.14% | Their influence decays by 13/14 per valid update. |
| EMA | 2/15 = 13.33% | Their influence decays by 13/15 per valid update. |
| SMA | 1/14 = 7.14% | The oldest value leaves the 14-observation window. |
Starting from the same previous average, EMA reacts more to a new price jump at equal lengths greater than one. SMA also changes when an old value leaves its window. There is no fixed number of bars by which SMMA always leads or trails SMA, and smoothing alone does not prove fewer losing trades.
Solving 1/N = 2/(M + 1) gives M = 2N - 1. Thus SMMA(14) and EMA(27) use the same recursive weight. They are not guaranteed to overlap from the start: ta.rma and ta.ema use different seeds. Read the SMA guide for rolling-window behavior or the EMA guide for exponential weighting.
Why the seed, chart history and missing values matter
SMMA and the RMA indicator describe the same algorithm here, consistent with TradingView's SMMA (RMA) label. To compare two plots, match their source, length, symbol, chart timeframe, session, offset and available history. A different starting history can produce a different seed even with the same length.
For two seeds differing by d, followed by identical valid inputs, the difference after k recursive updates is d × (1 - 1/N)^k. For N = 3 and d = 3, three updates reduce the difference to 3 × (2/3)³ = 0.8889. It has shrunk, not vanished. Choose a comparison tolerance and allow sufficient history before comparing values; there is no universal warm-up that makes every implementation identical.
The ta.rma reference specifies that missing source values, represented by na, are ignored. With N = 3, the sequence 100, na, 102, 104 first has enough valid values at the fourth chart bar, where the seed is 102. The length counts valid observations rather than elapsed clock time. Converting that missing value to zero would seed at the third bar with (100 + 0 + 102) / 3 = 67.3333, a different calculation.
A hand-written recurrence that directly adds an na source can produce na and then re-seed on the next bar. That is not the same missing-value policy as the built-in. Use ta.rma when you want Pine's documented behavior. Keep the calculation on every bar and apply any display or entry condition afterward.
Pine Script v6: compare averages and inspect a trend filter
This indicator plots SMMA using ta.rma and optionally shows EMA and SMA at the same length. The background highlights closed bars where the source is above SMMA and SMMA is rising. It is a filter example with no orders, exits or performance results.
//@version=6
indicator("SMMA / RMA comparison and trend filter", overlay=true)
length = input.int(14, "Length", minval=1)
source = input.source(close, "Source")
showComparison = input.bool(true, "Show same-length EMA and SMA")
smmaValue = ta.rma(source, length)
emaValue = ta.ema(source, length)
smaValue = ta.sma(source, length)
isReady = not na(source) and not na(smmaValue) and not na(smmaValue[1])
longFilter = barstate.isconfirmed and isReady and source > smmaValue and smmaValue > smmaValue[1]
plot(smmaValue, "SMMA (RMA)", color=color.blue, linewidth=2)
plot(showComparison ? emaValue : na, "EMA", color=color.orange)
plot(showComparison ? smaValue : na, "SMA", color=color.gray)
bgcolor(longFilter ? color.new(color.green, 88) : na, title="Long filter passes")The SMMA line updates on the open bar; the background waits for barstate.isconfirmed. A valid current source and a previous SMMA value are required. With complete data, the first possible filter decision is after N + 1 observations. It uses the chart timeframe and makes no higher-timeframe requests.
- Paste the code into a new TradingView Pine Editor indicator, save it and add it to the chart.
- Set Length, Source and chart timeframe explicitly. Compare with a built-in SMMA using matching inputs and zero offset.
- Inspect source, SMMA, EMA and SMA in the Data Window on closed bars. Allow for the loaded history when checking the first available values.
- Inspect an open bar separately. A changing line is expected; the filter highlight should wait for bar close.
Ranges can cause repeated filter changes, and a slow average can lag a reversal. A source selected from another indicator can have its own missing values or repainting behavior. Any strategy derived from this filter needs explicit execution, sizing, exit, fee and slippage rules plus separate testing. This material is educational and is not investment advice.
Specify an SMMA rule for Pineify
Pine Script AI Coding Agent can draft or revise a Pine Script document from your instructions. Give it the smoothing function, source, length and confirmation rule so the result can be checked against a defined calculation.
Create a Pine Script v6 indicator using ta.rma(close, 14) as SMMA on the chart timeframe. Highlight only closed bars where close is above SMMA and SMMA is higher than its previous value. Make Length and Source adjustable. Plot a same-length EMA for comparison. Do not place orders.
Review the generated source, check its syntax and compare the chart values before using it in a strategy. Code generation does not establish profitability or complete a backtest.
Frequently asked questions
Sources and related references
Official documentation checked October 17, 2026. Numerical examples are hypothetical calculations, not market results.
- TradingView smoothing settings: SMMA (RMA) naming
- Pine Script v6 reference: ta.rma formula, seed and na semantics
- Pine Script v6 reference: ta.ema coefficient and initialization
- TradingView: Simple Moving Average calculation
- TradingView: Bar states and confirmation
See the ta.rma API reference for argument types, or return to TradingView indicators.