All TermsIndicator

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

pinescript
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

Stop Reading. Start Trading.

PineForge backtests every concept on this site against real market data.

Try It Free

We use cookies for analytics and ads measurement. See our privacy policy.