3.4.1Indicators & Oscillators

Understand simple vs exponential moving averages

2,573 words12 min readdifficulty · medium1 backlinks

Overview

Moving averages smooth price data to reveal trend direction by filtering out short-term noise. The two fundamental types—Simple Moving Average (SMA) and Exponential Moving Average (EMA)—differ in how they weight historical data, leading to different responsiveness and lag characteristics.


Core Concepts


Derivation from First Principles

SMA: Why Arithmetic Mean?

Starting question: How do we represent "typical price over nn days"?

The simplest unbiased estimator is the arithmetic mean. No day gets preference:

SMAn=1ni=1nPi\text{SMA}_n = \frac{1}{n}\sum_{i=1}^{n} P_i

Why this step? Equal weighting assumes no day has special predictive value. Day 1 and Day 10 are treated identically.

Rolling mechanism: As time advances, we drop the oldest price and add the newest: SMAnew=SMAold+PnewPoldn\text{SMA}_{\text{new}} = \text{SMA}_{\text{old}} + \frac{P_{\text{new}} - P_{\text{old}}}{n}

Why this step? This is computationally efficient—we don't recalculate the entire sum, just adjust by the difference.


EMA: Why Exponential Weights?

Problem with SMA: When an old price drops out of the window, the SMA "jumps" because that entire 1n\frac{1}{n} weight vanishes instantly. This creates step discontinuities.

Solution concept: Instead of fixed windows, use a recursive formula where every past price contributes, but with exponentially decaying weight.

Derivation:

  1. Desired property: More recent prices should dominate. Let's say today's price gets weight α\alpha, and all prior history (summarized as yesterday's EMA) gets weight (1α)(1-\alpha).

EMAt=αPt+(1α)EMAt1\text{EMA}_t = \alpha P_t + (1-\alpha) \text{EMA}_{t-1}

Why this step? This is a weighted average of today's price and yesterday's smoothed value. The parameter α(0,1)\alpha \in (0,1) controls responsiveness.

  1. Choosing α\alpha: To make the EMA's "effective window" comparable to an nn-period SMA, we set:

α=2n+1\alpha = \frac{2}{n+1}

Why this step? This formula comes from matching the center of mass of the exponential decay to an nn-period uniform window. Proof:

The infinite expansion of EMA is: EMAt=αPt+α(1α)Pt1+α(1α)2Pt2+\text{EMA}_t = \alpha P_t + \alpha(1-\alpha)P_{t-1} + \alpha(1-\alpha)^2 P_{t-2} + \cdots

The weight on price kk days ago is α(1α)k\alpha(1-\alpha)^k. These weights sum to 1 (geometric series): k=0α(1α)k=α1(1α)=α=1\sum_{k=0}^{\infty} \alpha(1-\alpha)^k = \frac{\alpha}{1-(1-\alpha)} = \frac{\alpha} = 1 \quad \checkmark

The expected age (center of mass) is: Age=k=0kα(1α)k=1αα\text{Age} = \sum_{k=0}^{\infty} k \cdot \alpha(1-\alpha)^k = \frac{1-\alpha}{\alpha}

For an nn-period SMA, the average age is n12\frac{n-1}{2}. Setting these equal: 1αα=n12\frac{1-\alpha}{\alpha} = \frac{n-1}{2}

Solving for α\alpha: 2(1α)=α(n1)2(1-\alpha) = \alpha(n-1) 22α=αnα2 - 2\alpha = \alpha n - \alpha 2=αn+α2 = \alpha n + \alpha α=2n+1\alpha = \frac{2}{n+1}

Why this step? This ensures EMA(n)(n) and SMA(n)(n) have similar "lookback periods" but EMA responds faster because it never fully discards old data—it just diminishes it.


Visual Comparison

Figure — Understand simple vs exponential moving averages

Key observations:

  • SMA lags more during sharp moves (straight line segments in the SMA trace)
  • EMA curves smoothly and tracks current price more closely
  • Both converge during stable trends

Worked Examples


Common Mistakes


Practical Applications

When to Use SMA:

  1. Identifying major support/resistance: 200-day SMA is widely watched; its lag creates self-fulfilling prophecies as institutions use it.
  2. Filtering noise: In volatile stocks, SMA's smoothness prevents overtrading.
  3. Long-term trend confirmation: Lag is acceptable when you want to confirm a trend is established.

When to Use EMA:

  1. Short-term trading: 12/26-day EMAs in MACD indicator catch momentum shifts early.
  2. Trending markets: EMA hugs the price action better, keeping you in winning trades longer.
  3. Dynamic support/resistance: EMAs act as "moving floors/ceilings" that adapt faster.

Combinations:

  • Golden Cross: 50-day SMA crossing above 200MA (bullish). Uses SMA to avoid false signals.
  • MACD (Moving Average Convergence Divergence): Uses 12-day and 26-day EMAs to spot momentum changes.

Connections 3.4.02-Moving-average-crossovers-and-signals – How to generate buy/sell signals

  • 3.4.05-MACD-indicator – Uses EMA difference for momentum
  • 3.4.08-Bollinger-Bands – Built on SMA ± standard deviations
  • 2.3.03-Support-and-resistance-levels – Moving averages act as dynamic S/R
  • 3.2.04-Lag-vs-responsiveness-tradeoff – Fundamental tension in all smoothing

Feynman Recall

Recall Explain to a 12-year-old

Imagine you're trying to figure out if it's getting hotter or colder outside, but the temperature jumps around a lot minute-to-minute. You could: Method 1 (SMA): Every hour, average the last 10 minutes. At1:00, you average 12:50-1:00. At 1:01, you drop 12:50, add 1:01, and average the new 10 minutes. Each counts the same.

Method 2 (EMA): Instead of forgetting old minutes completely, you say "this minute's temperature is important, but so is the average I already calculated." You make a new average that's half today's temperature and half yesterday's average. Yesterday's average secretly includes the day before, and so on. So old temperatures fade out slowly like an echo, instead of vanishing suddenly.

The difference: Method 1 (SMA) reacts slower but is more stable. Method 2 (EMA) reacts faster but can be jumpy. If it's actually getting hotter, EMA figures it out quicker. If it's just a weird minute, SMA ignores it better.

For stocks, we want to know: "Is the price really going up, or just random noise?" Both methods help, but you pick based on whether you want to be fast (EMA) or careful (SMA).


Mnemonic


Formulas at a Glance


Active Recall Flashcards

#flashcards/stock-market

What is the formula for an n-period Simple Moving Average? :: SMA_n = (P_1 + P_2 + ... + P_n) / n, where each price has equal weight 1/n.

What is the recursive formula for Exponential Moving Average?
EMA_today = α·P_today + (1-α)·EMA_yesterday, where α = 2/(n+1).
Why does SMA create "step discontinuities" when a price drops out?
Because when an old price exits the window, its full1/n weight vanishes instantly, causing a sudden jump in the average.
What is the key difference in how SMA and EMA treat old data?
SMA gives equal weight to all n prices and completely discards older data. EMA gives exponentially decaying weight to all historical data—old prices never fully vanish.
What is the formula for the EMA smoothing factor α?
α = 2/(n+1). This makes the EMA's effective lookback period comparable to an n-period SMA.
Why do we initialize EMA with the first n-period SMA instead of the first price?
Starting with P_1 creates massive initialization bias. If early prices are unrepresentative, the EMA takes many periods to converge due to the compounding effect of (1-α).
In what market condition does EMA generate more false signals than SMA?
In sideways or choppy markets, EMA's higher responsiveness produces more whipsaws (false breakout signals) because it reacts to short-term noise.
What is the "effective age" or center of mass for an n-period EMA?
(1-α)/α = (n-1)/2, which matches the average age of an n-period SMA. This justifies the α = 2/(n+1) formula.
Why is the200-day SMA widely used as support/resistance?
Its lag and widespread institutional use create self-fulfilling prophecies—many traders watch it, so price often bounces at that level.
If α = 0.1 for an EMA, what percentage weight does today's price receive?
10%. The remaining 90% is the prior EMA value, which recursively embeds all historical prices.
What happens to SMA when the oldest price in the window equals the newest price?
The SMA remains unchanged because the drop and add cancel out: SMA_new = SMA_old + (P_new - P_old)/n = SMA_old when P_new = P_old.
For a 20-period EMA, approximately what weight does a price from20 days ago have?
α(1-α)^20 ≈ 0.095 × (0.905)^20 ≈ 0.095 × 0.134 ≈ 1.3%. Still present but heavily diminished.

Concept Map

smooth

reveal

two types

two types

uses

uses

is

old price drops

solved by

controlled by

equals

computed via

makes EMA

Moving Averages

Price Data Noise

Trend Direction

Simple MA

Exponential MA

Equal Weight 1 over n

Exponential Decaying Weight

Arithmetic Mean

Step Discontinuities

Smoothing Factor alpha

2 over n plus 1

Recursive Formula

More Responsive Less Lag

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Moving averages stock market mein trend ko samajhne ke liye bahut important hai. Jaise kiagar tum kisi hyperactive bache ko track kar rahe ho jo circle mein bhag raha hai, toh agle second ko predict nahi kar sakte, lekin last10 minutes ka average position dekho toh pata chalega ki wo ice cream truck ki taraf jaa raha hai. Yahi kaam moving averages karte hain—wo short-term noise ko filter karke underlying trend dikhate hain.

Do main types hain: Simple Moving Average (SMA) aur Exponential Moving Average (EMA). SMA bahut seedha hai—last "n" days ke prices ko add karke "n" se divide karo. Har din ka equal weight hota hai. Lekin problem yeh hai ki jab ek purana price window se bahar nikalta hai, SMA suddenly jump karta hai. EMA is problem ko solve karta hai by giving recent prices zyada weight. Formula recursive hai: aj ka EMA = alpha × (aj ka price) + (1 - alpha) × (kal ka EMA). Yahan alpha = 2/(n+1), jo decide karta hai kitni jaldi EMA respond karega.

Trading mein, SMA zyada stable hai lekin late signals deta hai—chopy markets ke liye acha hai jahan false breakoutszyada hote hain. EMA fast response deta hai, trending markets mein early entry/exit milta hai, lekin sideways markets mein zyada whipsaws (false signals) bhi de sakta hai. Professionals aksar dono ka combination use karte hain—jaise 50-day SMA aur 200-day SMA ka golden cross (bullish signal) ya phir MACD indicator jo12-day aur 26-day EMAs ka difference use karta hai. Core concept yeh hai: SMA stability deta hai, EMA speed deta hai—tumhe apni trading style ke hisaab se choose karna padega.

Test yourself — Indicators & Oscillators

Connections