SMMA — Smoothed Moving Average
תוכן זה אינו זמין עדיין בשפה שלך.
Wilder’s smoothed moving average (RMA): the recursive average ATR and RSI are built from.
Equivalent to an EMA with alpha = 1/n instead of 2/(n+1) — about twice as slow as an EMA of
the same period.
Signature
SMMA(period, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
period |
int Param or literal | Yes | Smoothing length. Default 14, bounds 1–400. |
on= |
symbol, OHLCV field, or indicator | No | Source. Defaults to the trade symbol’s close. |
Formula
$$ \text{SMMA}t = \text{SMMA}{t-1} + \frac{C_t - \text{SMMA}_{t-1}}{n} $$
seeded with the simple average of the first n values.
Warmup
period bars to seed. During the lead-in it returns the running average of the bars seen so
far; from bar n on, the recursion.
Reading the value
smma.valuesmma.crossed_above(other)price > smma.valueExample
class SmmaTrend(Strategy): """The Wilder-average trend filter: long above, flat below.""" period = Param(50, min=1, max=400) trade = Symbol() sizing = FixedCapital()
def execute(self): smma = SMMA(self.period, on=self.trade) if self.trade.close > smma.value and self.trade.is_flat: self.buy(self.trade, reason="Above SMMA") if self.trade.close < smma.value and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="Below SMMA")Variants
SMMA(14, on=tr) # ATR is exactly this, applied to true rangeSMMA(20, on=self.trade.high) # smoothed highsNotes
- Wilder, New Concepts in Technical Trading Systems (1978).
- Seeded with the simple average of the first
nbars (Wilder’s own convention). Because the recursion carries state, values in the first ~3n bars of a chart differ slightly from an implementation seeded elsewhere; they converge geometrically. - Proven by an assert-via-trade run on SPY daily (converged to a strategy-side Wilder recursion within 0.01 after 60 bars; zero alarm trades).
- A different recipe from pandas_ta’s
smma(7), not a different scale: measured on a 300-bar tape ours stays about 1.2 % away and never converges to it, because the construction (window offset, seed, weight normalisation) is its own.