SMA, EMA, WMA and HMA process prices under different rules. Equal period numbers do not imply equal weights, memory or responses. This guide specifies the calculations and works through WMA and every stage of HMA, including an output above all input prices.

One price series, four constructions

Let P[t] be the latest known closed-bar price, with t−1 the prior bar. Use backward-looking windows and ordinary candles in these models. Do not move calculated values to earlier decision times or include future prices.

Same input series, different required specifications
MethodCalculationSpecify
SMA(n)Sum of n prices / nFull window and applied price
EMA(n)E[t] = αP[t] + (1 − α)E[t−1], α = 2/(n + 1)Initial state and history
WMA(n)Linear weights 1 through n, oldest to newestWeight direction; divisor n(n + 1)/2
HMA(n)WMA of Q = 2 WMA(n/2) − WMA(n)Integer half/root periods and complete windows

SMA and WMA have finite price windows; EMA carries prior state. HMA includes subtraction, so its effective weights need not all be positive. A line outside the input range need not be an error or a forecast.

SMA and EMA: the latest weight is only part of the filter

SMA20 assigns each included price weight 1/20 = 5%. Conventional EMA20 assigns the new price α = 2/21 ≈ 9.5238% and carries the previous state with weight 19/21. Specify the seed and history before comparing outputs.

In a separate hypothetical example, let the new Close be 60 pips above both the outgoing SMA price and the previous EMA. Then SMA20 changes by 60/20 = 3 pips and EMA20 by 60×2/21 ≈ 5.7143 pips. This depends on those equal-baseline assumptions; it does not prove earlier turns or fewer losses for every path.

Same initial response, different decay

Before the impulse, every price and both averages equal 100. A new close of 106 gives WMA(3) and EMA(3) values of 103. Prices then return to 100. From the second update the lines differ: equal latest-price weight does not mean equal memory.

Scroll sideways to see the full diagram

WMA(3) and EMA(3) response to one impulseAfter impulse 106, WMA(3) gives 103,102,101,100 while EMA(3) gives 103,101.5,100.75,100.375. WMA forgets the impulse outside its window; EMA gradually reduces its influence.Same first move ≠ same memory103100t 0t 1t 2t 3t 4WMA(3): 103 → 102 → 101 → 100EMA(3): 103 → 101.5 → 100.75…New prices: 106, 100, 100, 100
Each point follows another added price. WMA(3) no longer contains 106 after three further closes of 100; EMA still carries part of the earlier state.

After price returns, WMA gives (100+2×106+3×100)/6=102, then (106+2×100+3×100)/6=101. EMA halves every deviation from 100: 3→1.5→0.75→0.375. When comparing strategies, record the complete filter type, not only period and initial reading.

Assumptions: Arbitrary series, earlier prices 100. WMA(3) weights are 1,2,3 from oldest, divisor 6. EMA(3) uses α=0.5 and initial state 100. Formula or data verification: Fidelity: EMA recurrence.

WMA: a finite window with linear weights

Take four hypothetical closes, oldest first: 100,100,100,110. WMA4 = (100 + 2×100 + 3×100 + 4×110)/10 = 104; SMA4 = 410/4 = 102.5. The difference comes from weights, without extra information about future prices.

For WMA20, the weight sum is 210 and the newest coefficient 20/210 = 2/21, identical to EMA20’s new-price coefficient. The rest of the weights and memory differ. WMA is not universally a midpoint between SMA and EMA responsiveness.

HMA: calculate Q, then its final WMA

Alan Hull describes an intermediate series Q[t] = 2 WMA(n/2)[t] − WMA(n)[t], then a WMA of Q with a period related to √n. A single Q value is not the final HMA. Specify integer period conventions and retain enough preceding Q values.

Choose n = 4, so both additional periods are exactly 2. Our entire hypothetical seven-close series is 100,100,100,100,110,110,110. Require full windows: Q first exists at bar 4; HMA4 first exists at bar 5. Missing history is not filled with zeros.

Hypothetical seven-price path; only displayed values are rounded
BarP[t]WMA2 / WMA4Q[t]HMA4[t]
4100100 / 100100Unavailable: only one Q
5110106.6667 / 104109.3333106.2222
6110110 / 107113111.7778
7110110 / 109111111.6667

At bar 5, WMA2 = 320/3; Q[5] = 2×320/3 − 104 = 328/3. HMA4[5] = (Q[4] + 2 Q[5])/3 = 956/9 ≈ 106.2222. The newer Q receives the larger weight. At bar 6, HMA4 = 1006/9 ≈ 111.7778 although no input exceeds 110. At bar 7 the line falls to 111.6667 while price remains 110: a filter turn and a price turn are different events.

Rounding a period changes the filter

StockCharts specifies nearest-integer rounding: HMA11 uses half-period 6 from 5.5 and final period 3 from √11 ≈ 3.3166. A truncation convention would use 5 and 3. These would be different filters with the same HMA11 label. Hull’s written formula uses Integer; check its meaning in the actual program rather than assuming one universal implementation.

Our n = 4 model avoids the fractional-period ambiguity. For another n, define minimum allowed periods, full-window requirements, missing values and applied prices. Compare the two price WMAs first, then Q and the final WMA.

Negative effective weights explain an HMA overshoot

Expanding our two stages gives these own algebraic HMA4 weights, from newest to oldest price: 28/45,5/9,−1/90,−2/15,−1/30. They sum to 1, but three are negative. This is an expansion of the stated filter, not a market observation.

Five prices of 100 give HMA4 = 100. Raise only P[t−3] to 110: the output changes by 10×(−2/15), falling to 98⅔. SMA5 on those same prices rises to 102. A weight sum of 1 reproduces a constant series; it does not ensure the output stays within the input range or rises when every individual input rises.

Equal first response does not mean equal memory

The diagram uses earlier prices of 100 and EMA3 state 100. A single new Close of 106 gives WMA3 and EMA3 = 103. Three subsequent closes of 100 give WMA3 = 102,101,100, while EMA3 = 101.5,100.75,100.375. EMA’s remaining deviation halves each time; WMA drops the impulse when it leaves its window.

The matching first reading follows from a new-price weight of 1/2 in both methods. It does not make their later paths interchangeable or predict a universal HMA/EMA/WMA ranking. The quiz’s EMA after three new prices of 100 is 100.375, not exactly 100.

A period and a line relation are not a complete strategy

SMA200 on M5 contains 1,000 represented minutes, or 16 hours 40 minutes when each bar represents its full interval. Trading breaks can lengthen calendar time. On D1 the same number denotes 200 daily observations. It assigns no universal trading style or direction.

Price relative to a mean, slope and a crossing are separate conditions. A chosen golden/death-cross convention describes the relation of specified averages; it does not establish a durable future regime. Nor do several transforms of one price series automatically provide independent confirmations.

Specify provider, instrument, applied price, interval, filter, period rounding, seed, history and decision time. Then define entries, exits, execution, costs and no-trade conditions before evaluating unused observations. A displayed colour change, selected screenshots, an hour of inspection or a month with frozen settings does not prove a profitable rule.

Reproduce the next HMA row

Add bar 8 with price 110. Both price WMAs now equal 110, Q[8] = 110, and HMA4[8] = (111 + 2×110)/3 = 331/3 ≈ 110.3333. It is still above price and falling despite unchanged Close.

Related reading: the SMA and EMA primer explains initialization; MACD introduces another transform involving exponential averages; multi-timeframe analysis develops information timing across intervals. Keep the full filter specification when building a test.