WilderAverage
WilderAverage in ProBuilder returns Wilder's smoothed moving average of a price over N bars, the smoothing used inside RSI and ATR. Syntax, formula, examples.
Syntax
WilderAverage[N](price)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
N | integer | 20 | Lookback period. The effective smoothing factor is 1/N, so larger values produce a much slower line. |
price | price source | close | The series being smoothed. Accepts close, open, high, low, or any custom variable. |
Formula
WilderAverage = previousWilderAverage + (price - previousWilderAverage) / NEquivalently, it is an exponential moving average with alpha = 1/N. A standard EMA uses alpha = 2/(N+1), so a Wilder average of period N behaves like a regular EMA of period 2N - 1.
How it works
Each bar, the Wilder average moves a fraction 1/N of the distance from its previous value toward the current price. Recent bars therefore carry more weight than older ones, but the small smoothing factor means the line adjusts gradually and filters out most bar-to-bar noise.
The method exists because Wilder designed his 1978 indicators for manual calculation: the recursive form needs only the previous value and the new price. RSI, AverageTrueRange, and ADX all use this smoothing internally. When rebuilding or modifying one of those indicators, using WilderAverage rather than ExponentialAverage is what keeps the output identical to the platform's built-in version.
The main practical consequence of the 1/N factor is lag. A WilderAverage[14] is roughly as slow as a 27-period EMA, so period settings do not transfer directly between average types.
Examples
Example 1, Wilder-smoothed MACD variant (Indicator)
// Difference between a 26- and a 12-period Wilder average
long = WilderAverage[26](close)
short = WilderAverage[12](close)
WilderMACD = long - short
RETURN WilderMACDBuilds a MACD-style oscillator from two Wilder averages instead of standard EMAs, producing a smoother, slower signal line. This is the source example with rewritten comments.
Example 2, Trend filter for a breakout system (ProOrder)
// Only trade breakouts in the direction of the Wilder-smoothed trend
trend = WilderAverage[50](close)
IF NOT OnMarket THEN
IF close > trend AND close CROSSES OVER Highest[20](high)[1] THEN
BUY 1 CONTRACT AT MARKET
ENDIF
ENDIF
IF LongOnMarket AND close CROSSES UNDER trend THEN
SELL AT MARKET
ENDIFA 50-period Wilder average defines the trend. Long breakouts are only taken above the line, and positions close when price crosses back under it.
Example 3, Screening for pullbacks to the Wilder average (ProScreener)
// Uptrending instruments pulling back close to their Wilder average
wa = WilderAverage[21](close)
uptrend = wa > wa[10]
nearline = ABS(close - wa) / wa < 0.01
SCREENER[uptrend AND nearline](((close / wa) - 1) * 100 AS "% vs WA")Selects instruments whose 21-period Wilder average is rising and whose price sits within 1 percent of the line, a pullback-in-trend setup.
Interpretation
A Wilder average is read like any moving average: price above a rising line suggests an uptrend, price below a falling line suggests a downtrend, and crossovers between price and the line, or between two lines of different lengths, mark potential trend changes.
Relative to other averages of the same period it is one of the slowest options available, smoother than Average and much smoother than ExponentialAverage. That makes it better suited to trend filters and volatility smoothing than to fast signal generation. When responsiveness matters more than stability, ExponentialAverage, WeightedAverage, or ZLEMA are the usual alternatives.
Common errors and gotchas
- Treating the period like an EMA period.
WilderAverage[14]is far slower thanExponentialAverage[14]. To match an existing EMA, use roughly half the period plus one, and to match a Wilder average with an EMA, use2N - 1. - Wrong bracket types. The period belongs in square brackets and the price in parentheses:
WilderAverage[26](close).WilderAverage(26, close)does not compile. - Reproducing RSI or ATR with the wrong smoothing. Rebuilding Wilder indicators with
ExponentialAverageorAverageproduces values that drift away from the built-ins. UseWilderAveragefor exact matches. - Early-bar warm-up. As a recursive average, the line needs a number of bars to converge after the start of the data series. Values on the first few dozen bars of a chart or backtest are less reliable.
Related instructions
Average, simple moving average.ExponentialAverage, standard EMA withalpha = 2/(N+1).WeightedAverage, linearly weighted moving average.RSI, momentum oscillator built on Wilder smoothing.AverageTrueRange, volatility measure using the same smoothing.ADX, trend-strength indicator from the same Wilder family.ZLEMA, reduced-lag exponential average.HullAverage, low-lag alternative built from weighted averages.
