In this article
After this article, you can
- Compare moving-average memory after the same impulse.
- Record filter type as well as period.
Terms at hand: Exponential Moving Average (EMA) · Simple Moving Average (SMA) · Stop loss · Take profit (TP) · Backtesting · MACD (Moving Average Convergence Divergence)
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.
| Method | Calculation | Specify |
|---|---|---|
| SMA(n) | Sum of n prices / n | Full 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 newest | Weight 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
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.
| Bar | P[t] | WMA2 / WMA4 | Q[t] | HMA4[t] |
|---|---|---|---|---|
| 4 | 100 | 100 / 100 | 100 | Unavailable: only one Q |
| 5 | 110 | 106.6667 / 104 | 109.3333 | 106.2222 |
| 6 | 110 | 110 / 107 | 113 | 111.7778 |
| 7 | 110 | 110 / 109 | 111 | 111.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.
Check your understanding
One short exercise
About 2 min · you can try again
After three new closes of 100, WMA(3) returns to 100. Must EMA(3) also equal exactly 100?
- Yes; both periods are 3.
- No; this model gives 100.375.
- No; it must exceed 103.
Check the answer and explanation
No; this model gives 100.375.
The initial deviation of 3 halves three times to 0.375.
Frequently asked
Does WMA always respond more slowly than EMA?
No universal order holds for every series. WMA20 and EMA20 share a new-price coefficient 2/21, but their other weights and memory differ. In the impulse model, WMA3 and EMA3 first equal 103, then take different paths despite identical new prices.
Can HMA lie outside its input-price range?
Yes. HMA4 at bar 6 is about 111.7778 while the input maximum is 110. Subtraction creates negative effective weights. Raising one older price can even lower the current output. This is filter arithmetic, not a traded price or a forecast.
Why can two HMA11 implementations disagree?
They can use different integer conventions for half-period and square root, as well as different prices, history or missing-value handling. StockCharts uses 6 and 3 for HMA11; truncating the half-period instead gives 5. Compare each WMA, Q and the final smoothing separately.
Does a period of 200 define a long-term trend?
The number alone does not. On M5 it means 1,000 represented minutes; on D1, 200 daily bars. Specify the interval, data and meaning of trend. Neither broad popularity claims nor a crossing certifies future direction or a profitable entry.
Sources & bibliography
-
John J. Murphy / Penguin Random House Technical Analysis of the Financial Markets (1999), chapter on moving averages · New York Institute of Finance, 1999; discusses moving averages and their variants. www.penguinrandomhouse.com ↗
-
Alan Hull How to Reduce Lag in a Moving Average · Alan Hull's description of the Hull Moving Average, associated with its 2005 introduction. alanhull.com ↗
-
StockCharts ChartSchool Moving Averages — Simple and Exponential · Explains moving-average formulas and parameters, with comparisons of simple and exponential averages. chartschool.stockcharts.com ↗
-
Investopedia Moving Average (MA) · Explains moving-average types and the conventional golden-cross and death-cross terms. www.investopedia.com ↗
-
Alan Hull The Hull Moving Average · The author describes the three-WMA construction and Integer notation. Own worked examples explore the formula; promotional smoothness or trading claims are not certified results. alanhull.com ↗
-
StockCharts ChartSchool Hull Moving Average — calculation and rounding · Specifies the intermediate series, final WMA and nearest-integer example using half-period 6 and root-period 3 for HMA11. Other integer conventions create a different filter. chartschool.stockcharts.com ↗
-
MetaQuotes MetaTrader 5 Help — Moving Average calculations · Documents SMA, EMA, SMMA and linear-weighted formulas. Definitions of the filters do not demonstrate a trading edge. www.metatrader5.com ↗
