TrendReference · Indicator Library

EMA

Exponential Moving Average

A weighted moving average that gives more influence to recent prices, making it more responsive to new information than a simple moving average.

EMA is a weighted moving average that gives recent prices more influence than older ones, making it more responsive than a simple moving average. Common lengths are 9 and 21 for short-term, 50 for medium-term, and 200 for long-term trend. Used as dynamic support/resistance and as a trend-bias filter.

The EMA applies an exponentially decaying weighting to past prices — the most recent bars influence the average most, older bars fade out. This makes the EMA react faster to price changes than an SMA of the same length, at the cost of being slightly noisier.

Common lengths: 9/21 for short-term, 50 for medium-term, 200 for long-term trend. EMAs are used in three main ways: as dynamic support/resistance, as trend filters (price vs EMA), and as crossover signals between two EMAs of different lengths.

How do I read EMA?

  • Price above the EMA = bullish bias. The line acts as dynamic support during pullbacks.
  • Price below the EMA = bearish bias. The line acts as dynamic resistance on bounces.
  • Slope direction matters: a rising EMA = uptrend, falling EMA = downtrend. A flattening EMA signals a regime in transition.
  • Two-EMA crossovers (9 over 21, or 50 over 200) signal regime shifts. A faster EMA crossing the slower one is the textbook "golden cross" (bullish) or "death cross" (bearish).
  • Distance matters: price stretched far above the EMA on a fast move is overextended; expect a pullback toward the line.

How is EMA calculated?

EMA is computed recursively, with each bar's contribution decaying exponentially over time. The smoothing factor α determines how heavily recent bars are weighted versus older ones.

  1. 1.Choose a length N (typically 9, 21, 50, or 200).
  2. 2.Compute the smoothing factor: α = 2 / (N + 1).
  3. 3.Initialize: the first EMA value equals the first close (or an SMA of the first N bars).
  4. 4.For each subsequent bar: EMA = (close × α) + (EMA[1] × (1 − α)).
  5. 5.The result is a moving average where the most recent bar has the largest weight and older bars decay exponentially.

What are the default EMA settings?

ParameterDefaultWhen to adjust
Short-term length9 or 219 EMA for very short-term timing on intraday charts; 21 EMA for daily-chart short-term trend.
Medium-term length50Industry-standard medium-term trend filter. Pullbacks to the 50 EMA in uptrends are common buy zones.
Long-term length200The classic long-term trend filter. Price above 200 EMA = bullish regime; below = bearish.
SourceCloseMost common. HLC3 or HL2 reduces wick noise on volatile assets.

How do I plot EMA in Pine Script?

//@version=5
indicator("EMA Example", overlay=true)

fastLen = input.int(21, title="Fast Length", minval=2)
slowLen = input.int(50, title="Slow Length", minval=2)
src     = input.source(close, title="Source")

emaFast = ta.ema(src, fastLen)
emaSlow = ta.ema(src, slowLen)

plot(emaFast, title="EMA Fast", color=color.blue,   linewidth=2)
plot(emaSlow, title="EMA Slow", color=color.orange, linewidth=2)

Pine's ta.ema() handles the recursive calculation for you, so you don't need to track previous EMA values manually. Plotting two EMAs (a fast and slow length) overlaid on price gives you both trend direction and crossover signals in one indicator. Use overlay=true so the EMAs draw on the same pane as price.

Continue exploring

Related indicators

Browse all indicators

About this reference

This page is an educational reference explaining what EMA is, how it is calculated, its default settings, and how to plot it in Pine Script. It is compiled from established trading literature and public technical documentation. Last review: .

Educational content. Not financial advice.