VariablePeriodWildersMA
Background
Wilder's moving average — also known as the Wilder smoothing or RMA — was introduced by J. Welles Wilder and is the smoothing engine behind classic indicators such as RSI, ATR and DMI. It is a form of exponential averaging that reacts more slowly than a standard EMA of the same length: a Wilder average of n periods behaves roughly like an EMA of 2n−1 periods. That gentle smoothing makes it well suited to filtering noise without introducing too much lag.
A standard Wilder average uses one fixed period. VariablePeriodWildersMA
accepts a period for each bar, so the amount of smoothing adapts as
the market changes. The per-bar periods normally come from an adaptor such as the
DominantCycle or DominantCycle, or any array you
build yourself.
Included formula
The toolbox ships a ready-made Adaptive Wilders MA indicator built on this function, so you can use it without writing any code. In AmiBroker open the Charts window, expand the WiseTraderToolbox group and drag Adaptive Wilders MA onto a price chart.
It plots Wilder's average right on top of price. The Adaptor you pick is what produces the per-bar period this function needs — so the smoothing tightens and loosens with the market — and an optional Smoother cleans up the price first. The adaptor's bounds, the smoothing and the line colour are all set from the indicator's parameters.
The exported function
If you would rather build your own formula, the toolbox exports the calculation as a single AFL function you can call directly — it is the engine inside that indicator.
VariablePeriodWildersMA(Price, Periods)
| Parameter | Description |
|---|---|
| Price | The price array the moving average is calculated on. |
| Periods | An array (or value) giving the smoothing period to use at each bar. Most often
this is fed from an adaptor such as the DominantCycle. |
Usage
periods = DominantCycle( Close );
Plot( Close, "Price", colorDefault, styleBar );
Plot( VariablePeriodWildersMA( Close, periods ), "Adaptive Wilder MA", colorRed );