Exponential Moving Averages: Weighting, Lag and Trend Signals
Table of Contents
A stock jumps from $102 to $114, then gives back the gain over the next few sessions. The close turns down right away, but one of its moving averages keeps rising. A three-session exponential moving average (EMA) assigns 50% weight to each new close after the starting value. A three-session simple moving average assigns it one-third. That difference helps explain how the two lines respond to the jump and the fade.
What Is an Exponential Moving Average?
An EMA smooths a series of prices by combining the latest price with the previous average. It starts from a value called a seed, then updates once per bar. A bar is one observation interval, such as a trading session. This article uses the closing price of each completed bar.[1][2]
A simple moving average (SMA) weights the last N closes equally and drops each close when it leaves that window. After the starting value, each EMA update gives the new close a fixed weight and reduces the weights already in the average. The EMA’s period sets how quickly those earlier influences fade.[3][6]
The EMA Formula and Its Weights
Let Pt be the current close and Et−1 the EMA from the previous bar. The smoothing factor alpha determines the fraction of the gap between them that the EMA closes on this update.[1][2][5]
Each later bar multiplies a close’s influence by (1 − α). With a 3-bar EMA, α = 2 / (3 + 1) = 0.50. Once three closes have arrived after the seed, their weights are 50% for the latest, 25% for the preceding close and 12.5% for the one before that. The seed carries the remaining 12.5% at that point, and its weight keeps halving with each new close.[1][3]
How to Start an EMA
On the first row of a price file you have the close but need a previous average to apply the update formula. Two conventions supply that starting value.
- First full SMA. Average the first N closes, put the result on bar N and start the EMA updates on bar N + 1. This is the rule in TA-Lib’s default compatibility setting when processing the series from its beginning.[2]
- First close. Set the EMA on the first bar equal to that bar’s close, then update on the second bar. The pandas exponentially weighted mean uses this convention with
adjust=Falseon a complete price series.[3]
Once both versions use the same closes and alpha, only their starting values account for the difference. The common current-price term cancels when you subtract the two updates. The remaining gap is (1 − α) times the gap from the previous bar. A longer span has a smaller alpha and keeps more of that gap with each update.[1][3]
Worked Example: One Jump, Two EMA Seeds
Suppose a stock closes at $96, $102 and $102 over three sessions. On Jan. 8 it jumps to $114, then fades through $107 and $103 before settling at $100. Compare the two 3-bar EMAs and a 3-bar SMA using exactly those hypothetical daily closes. The 3-bar EMA moves half the distance from its previous value to the current close on each update.
On Jan. 7, the full-window SMA is ($96 + $102 + $102) / 3 = $100. That is also the SMA-seeded EMA’s first value. The first-close EMA starts at $96 on Jan. 5, moves to 0.50 × $102 + 0.50 × $96 = $99 on Jan. 6 and reaches 0.50 × $102 + 0.50 × $99 = $100.50 on Jan. 7.
With the Jan. 8 close of $114, the SMA-seeded EMA becomes 0.50 × $114 + 0.50 × $100 = $107.00. The first-close EMA becomes 0.50 × $114 + 0.50 × $100.50 = $107.25. The rolling SMA is ($102 + $102 + $114) / 3 = $106.00.
| Session | Close | SMA | EMA (SMA seed) | EMA (first close) |
|---|---|---|---|---|
| Jan. 5 | 96.00 | – | – | 96.00 |
| Jan. 6 | 102.00 | – | – | 99.00 |
| Jan. 7 | 102.00 | 100.00 | 100.00 | 100.50 |
| Jan. 8 | 114.00 | 106.00 | 107.00 | 107.25 |
| Jan. 9 | 107.00 | 107.67 | 107.00 | 107.13 |
| Jan. 12 | 103.00 | 108.00 | 105.00 | 105.06 |
| Jan. 13 | 100.00 | 103.33 | 102.50 | 102.53 |
| Jan. 14 | 100.00 | 101.00 | 101.25 | 101.27 |
| Jan. 15 | 100.00 | 100.00 | 100.63 | 100.63 |
The dashes mark the sessions before a full SMA window is available. The gap between the two EMA seeds is $0.50 on Jan. 7 and $0.25 on Jan. 8. By Jan. 15 it is about $0.008, even though the two displayed values round to the same cent.
EMA vs. SMA: How Each Line Lags the Price
3-bar EMA with the SMA seed
The Jan. 8 jump lifts the EMA $7. On Jan. 9 it stays at $107 because the new close equals the prior EMA. The $103 close on Jan. 12 then pulls the EMA down by half of the $4 gap, to $105.
3-bar SMA
The Jan. 8 jump lifts the SMA $6 from the same $100 starting point. On Jan. 12 it rises again because $103 replaces $102 in the window. The new close is lower than the preceding day’s close but higher than the one that rolls out.
For the same length greater than one, a change to the latest close has a larger immediate effect on the EMA than the SMA: its weight is 2 / (N + 1) versus 1 / N. But how long the two lines take to turn or reach the new level depends on the price path. By Jan. 15 the SMA has three $100 closes and equals $100. The SMA-seeded EMA still includes some influence from earlier closes, leaving it about $0.63 above the current close.[4][6]
How to Read the EMA’s Direction
An EMA slopes upward when the latest close is above the previous EMA and downward when it is below. On Jan. 9 the close falls from $114 to $107 while the SMA-seeded EMA remains flat. The close has fallen relative to the previous close and is unchanged relative to the previous EMA. Those are two different comparisons.[1][4]
Choose a shorter length when you want the line to react more to each new close. A 20-bar EMA gives the latest close 2 / 21, or about 9.52% weight. A 50-bar EMA gives it 2 / 51, or about 3.92%. Keep the bar interval in view. Twenty daily bars and twenty hourly bars refer to different stretches of time. For an application that compares two moving averages, see the EUR/USD crossover example.[3][4]
Another way to compare two EMAs is to subtract the slower average from the faster one. The MACD indicator guide then shows how the signal line and histogram describe changes in that difference.
How to Compare the Two Averages in Excel
To recreate the hypothetical example, enter the closes oldest to newest. Use Excel’s AVERAGE on each complete three-close window for the SMA. Carry each prior EMA forward as the starting point for the next row’s update. Keep the full precision in the calculation and round the displayed values.[9]
For a separate comparison on historical ticker data, the two MarketXLS calls below use the syntax documented for Excel Desktop on Windows. Both request a 20-period average for the same ticker as of Jan. 15, 2026.[5][6][7]
=ExponentialMovingAverage("AAPL","20",DATE(2026,1,15))=SimpleMovingAverage("AAPL","20",DATE(2026,1,15))
Compare those outputs with a hand calculation using matching dates and closes. The ticker functions supply their own prices and may use an earlier starting point for the EMA. MarketXLS also documents a separate tool that runs technical indicators on prices already in a worksheet.[5][6][7]
Common Mistakes When Comparing EMA Values
- Matching only the visible dates. Two charts may show the same closes but start calculating at different points. Check the seed, when each output begins and how much prior history each calculation uses.[2][3]
- Mixing raw and adjusted prices. Check whether prices are adjusted for corporate actions, and use the same basis for both averages. A split can change the appearance of the raw series.[8]
- Mixing bar definitions. Compare completed bars at the same interval and session cutoff. For one close per trading session, count an exchange closure as no bar. Check for a missing value on an actual trading day before calculating the average.[3]
Where EMA Trend Signals Can Mislead
The EMA summarizes prices already observed. A shorter span follows a fresh move more quickly, including a move that soon reverses. In a sideways stretch, several closes on alternating sides of the line can make the apparent trend change frequently. A rising or falling EMA therefore describes recent history. Whether a trading rule based on it works requires separate evidence.[4]
To see how smoothing changes the apparent size and timing of a move, compare the same observations under several time-series smoothing methods.
Frequently Asked Questions
Use the same history and seed when you want an exact comparison. For different starting values and otherwise identical inputs, a 20-bar EMA retains about 13.5% of the starting gap after 20 updates, because (19 / 21)20 ≈ 0.135. Load enough prior closes for any remaining difference to be small at the precision you need.[1][3]
Both reduce the influence of older observations geometrically. The price EMA smooths closing prices and produces a price. The EWMA volatility model weights squared returns to estimate variance, whose square root gives volatility.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, EWMA Control Charts, section 6.3.2.4 and Single Exponential Smoothing, section 6.4.3.1.
- TA-Lib, EMA formula and initialization in the v0.6.4 implementation.
- pandas, Exponentially weighted calculations, version 2.3, span and adjustment settings.
- Fidelity Learn, Exponential Moving Average.
- MarketXLS, Exponential Moving Average (EMA) formula documentation.
- MarketXLS, Simple Moving Average (SMA) formula documentation.
- MarketXLS, Technical Indicators in Excel.
- MarketXLS, Understand Splits, Dividends, and Adjusted Prices.
- Microsoft Support, AVERAGE function.
Educational Use
This article is for general education. The worked example uses hypothetical share prices.
