EMA (Exponential Moving Average)
An exponential moving average is a type of moving average that places greater weight on the most recent price data, so it reacts faster to new information than a simple moving average (SMA) of the same length.
Why traders use EMA
The EMA is the most-used indicator in algorithmic trading because it captures trend direction with minimal lag. The formula is recursive — each new EMA value depends on the previous one — which makes it efficient to calculate on streaming bars.
Formula
EMA = (close × k) + (previous EMA × (1 − k)), where k = 2 / (length + 1).
For a 21-period EMA, k ≈ 0.0909. Each new bar contributes ~9% to the running value.
EMA in Pine Script
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)Common pairings
The 9/21 and 50/200 EMA pairs are the most-used trend-following setups. See EMA Crossover for a complete strategy template.
Strategies that use EMA (Exponential Moving Average)
Related Terms
SMA (Simple Moving Average)
The simple moving average is the unweighted mean of the last N bars — slower to react than an EMA but with smoother output.
RSI (Relative Strength Index)
The RSI oscillates between 0 and 100, measuring the velocity of recent gains vs losses to identify overbought and oversold conditions.
Crossover
A crossover happens when one series crosses above another — used as the entry signal in moving-average and oscillator-based strategies.
Stop Reading. Start Trading.
PineForge backtests every concept on this site against real market data.
Try It Free