◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Indicators / Weighted Moving Average (WMA)
Moving Averages indicator

Weighted Moving Average (WMA)

A moving average with linearly declining weights — the newest bar counts most, the oldest counts least, and the window has a hard edge.

Illustrative diagram — not live market data.

What it is

A Weighted Moving Average (WMA) is a moving average in which each bar in the lookback window is multiplied by a linearly declining weight: in a 10-bar WMA, the newest bar gets weight 10, the next 9, and so on down to 1 for the oldest, with the total divided by the sum of the weights (55, or n(n+1)/2 in general). This makes the WMA more responsive to recent price than a Simple Moving Average of the same length, which weights all bars equally. The natural comparison — and the most common question — is against the EMA, which also emphasizes recent bars but does it differently: EMA weights decay exponentially and never quite reach zero, so every past bar contributes a little, forever, while WMA weights fall in a straight line and cut off completely at the window edge. Neither scheme is 'better'; they are two different, fully deterministic answers to the same smoothing problem, with different lag and cutoff behavior. The WMA is also the building block of the Hull Moving Average, which combines three WMAs. Like all moving averages, a WMA summarizes past prices and predicts nothing; this entry is educational only, not financial advice, and trading involves risk of loss.

How it works

For a WMA of length n, take the last n prices, multiply the most recent by n, the one before by n−1, continuing down to weight 1 for the oldest, sum the products, and divide by n(n+1)/2. Plotted as weight curves, the difference from other averages is immediate: the SMA is a flat block (every bar equal), the WMA is a straight descending ramp that hits zero at bar n, and the EMA is an exponential decay curve — steep at first, then a long thin tail that never fully reaches zero. Two practical consequences follow from those shapes. First, responsiveness: because the WMA concentrates weight on recent bars, its effective lag is about (n−1)/3 bars, versus (n−1)/2 for an SMA of the same length — a 20 WMA turns noticeably sooner than a 20 SMA. Compared at equal nominal length, a WMA typically responds slightly faster than an EMA, whose defining tail drags some old information along. Second, the cutoff: a WMA forgets a bar completely the moment it leaves the window, so a single large old bar dropping out can nudge the line even when current price is quiet; an EMA never has this drop-out effect because nothing ever fully exits, it only fades. Both behaviors are correct implementations of their definitions — which artifact you prefer to live with is the real choice.

How traders read it

Common settings

Lengths mirror other moving averages: 9-20 for short-term reads, 50 for intermediate, 100-200 for longer context, usually on the close. There is no standard 'WMA length' distinct from SMA/EMA conventions. When comparing WMA to EMA, compare at equal nominal length but expect slightly different lag — matching their effective lag exactly requires different lengths. In Pine Script the built-in is ta.wma(source, length); in MetaTrader it is the 'Linear Weighted' MA mode.

Strengths

Pitfalls to watch

Pine v6 example

//@version=6
indicator("WMA vs EMA vs SMA", overlay = true)

len = input.int(20, "Length", minval = 1)
src = input.source(close, "Source")

wmaLine = ta.wma(src, len)
emaLine = ta.ema(src, len)
smaLine = ta.sma(src, len)

plot(wmaLine, "WMA", color = color.blue)
plot(emaLine, "EMA", color = color.orange)
plot(smaLine, "SMA", color = color.gray)

Pro tip: Plot a 20 WMA, 20 EMA, and 20 SMA together (the example above does this) and watch a few sharp moves: the WMA turns first, the EMA close behind, the SMA last — and in chop, the ordering of whipsaws is the same. That one chart answers 'WMA vs EMA' better than any rule of thumb: you are choosing a weight curve and its artifacts, not a performance edge. If you need identical values across platforms, prefer the WMA's finite window — EMA values can differ slightly depending on how much history each platform seeds. Educational only, not advice; all moving averages lag, none predict, and trading involves risk of loss.

Built an indicator from this? Run it through the Validator to catch look-ahead bias and repainting, or convert a strategy to Pine Script.

Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro