EMA
An EMA (exponential moving average) is a weighted average of price in which the weights decay exponentially with age: the newest bar counts most, and each older bar counts a fixed fraction less. EMA, also known as exponential moving average, is a Trend concept. The Library holds 2 implementations, each one ready to run on Vela.
Top EMA indicators
The top custom implementations, built on the original standard EMA formula.
2 total
Want to trade EMA? Put the top implementation below on a live chart in Vela, and Quant will help you build a strategy on it and backtest it.
What is an EMA?
An EMA (exponential moving average) is a weighted average of price in which the weights decay exponentially with age: the newest bar counts most, and each older bar counts a fixed fraction less. In its recursive form, each new EMA value equals a smoothing factor alpha times the current price, plus (1 minus alpha) times the previous EMA value. Charting convention sets alpha to 2 divided by (length + 1), so a 20-period EMA uses an alpha of roughly 0.095.
The exponential weighting is what separates it from an SMA, which weights every bar in its window equally and drops the oldest bar entirely. An EMA never fully drops anything: old data fades smoothly rather than falling off a cliff, and the stated length is really a convention for choosing alpha, not a hard window. The result is a smoother roll and a faster response to new prices at the same nominal length. Exponential smoothing was not invented for markets; it came out of 1950s forecasting and inventory research before technical analysts adopted it.
The EMA matters because it is the workhorse smoother of technical analysis. It defines trend direction and dynamic support in countless templates, and it sits inside other indicators: MACD is the difference between two EMAs, and many oscillator signal lines are EMAs of the oscillator. Its lag-versus-smoothness tradeoff also spawned a whole lineage of successors, from DEMA and TEMA to adaptive designs like KAMA.
How to calculate an EMA
The EMA is a one-line recursion; the only real decisions are the length and the seed:
- 1Choose a length N and convert it to the smoothing factor: alpha = 2 / (N + 1). A 9-period EMA uses alpha of 0.2; a 200-period EMA uses roughly 0.01.
- 2Seed the series. Most platforms start the EMA at the first available price or at the simple average of the first N bars; the choice only affects early values, because the seed's influence decays exponentially.
- 3Update recursively on every bar: the new EMA equals alpha times the current close plus (1 minus alpha) times the prior EMA.
- 4Read it like any moving average: slope for direction, price's position above or below the line for bias, and distance from the line for stretch.
How it's calculated
An EMA is a moving average whose weights decay exponentially, so recent bars count more than older ones.
The two seeding conventions only differ on early bars and converge quickly.
Wilder's smoothing (RMA) is the same recursion with alpha = 1 / n, so a 14-bar RMA weights history like a 27-bar EMA.
How traders use it
- As a trend filter: price holding above a rising EMA frames a long bias, price below a falling one frames a short bias. The 9, 20/21, and 50 lengths are common intraday and swing choices, with the 200 serving as the classic long-horizon reference.
- As dynamic support and resistance: trending markets often pull back to a widely watched EMA and react there, the behavior covered under dynamic S/R via MA. The line is a zone of interest, not a guarantee.
- In crossover systems: a fast EMA crossing a slow one is the standard trend-change trigger, formalized in moving average crossovers and extended into an MA ribbon when many lengths are plotted at once.
- As a building block: EMAs smooth other series as often as they smooth price. MACD, signal lines, and smoothed oscillators all reuse the same recursion, and Wilder's indicators run on the closely related RMA.
EMA vs similar moving averages
SMA: Equal weights across a fixed window versus exponentially decaying weights. The SMA drops its oldest bar abruptly, which can kink the line when a large bar exits the window; the EMA fades old data smoothly and turns faster at the same stated length.
WMA: Both front-weight recent prices, but the WMA's weights decline linearly toward zero across a hard window, while the EMA's decline geometrically and never quite reach zero. The WMA is fully window-bound; the EMA carries a long, fading memory.
RMA: Wilder's smoothing is the same recursion with alpha = 1/N instead of 2/(N+1), so it is heavier and slower at the same stated length. RSI and ATR are built on it, which is why they feel smoother than an EMA-based equivalent of the same period.
DEMA: The DEMA combines an EMA with an EMA of that EMA to cancel lag rather than merely shorten it. It hugs price more tightly in trends but overshoots more at turns; the plain EMA is the more conservative default.
EMA FAQ
Turn EMA into a trading strategy.
Open the top implementation from this page in Vela. Quant, our coding agent, builds the strategy with you and backtests it on real data.
Browse this familyTrend104 concepts mapped · 104 in the Library
- Adaptive-lookback MA
- ADX / DMI System
- Alligator
- ALMA
- Anchored MA
- Andrews' Pitchfork
- Aroon
- ATR Trailing Regime
- Bessel Filter
- Breakout
- Butterworth Filter
- Chande Kroll Stop
- Chandelier Stop
- Chebyshev Filters
- Climactic Moves
- Continuation
- Coral Trend
- Correlation Trend Indicator
- Death Cross
- DEMA
- Displaced MA
- Donchian Trend Rules
- Dynamic S/R Via MA
- Ehlers Instantaneous Trendline
- Ehlers SuperSmoother
- Elastic Volume-weighted MA
- Elliptic Filter
- EMA
- Fan Principle
- FRAMA
- Gann Box
- Gann Fan & Angles
- Gann HiLo Activator
- Gann Method
- Gann Square of 9
- Gaussian Filter
- Geometric MA
- Golden Cross
- Guppy GMMA
- Halftrend
- Harmonic MA
- Higher-timeframe Trend Filter
- HMA
- Ichimoku Signals
- Ichimoku System
- Ichimoku Theories
- JMA
- KAMA
- Kaufman Efficiency Ratio
- Laguerre Filter
- Linear-regression Channel
- LSMA
- MA Envelope
- MA of MA
- MA Ribbon
- MA Slope Filter
- MAMA/FAMA
- McGinley Dynamic
- MLMA
- Moving Average Crossovers
- NRTR
- Order-statistic Filters
- Parabolic SAR
- Parallel Channel
- Polynomial Regression Band
- Pullback
- R-squared Trend Fit
- Rainbow MA Stack
- Random Walk Index
- Range Filter
- Retest
- Reversal
- RMA
- Savitzky-Golay Filter
- Sine-weighted MA
- SMA
- Speed Resistance Lines
- Standard-error Channel
- Supertrend
- Swiss Army Knife Filter
- SWMA
- T3
- TEMA
- TRAMA
- Trend Acceleration/inflection
- Trend Exhaustion
- Trend Intensity Index
- Trend Magic
- Trend Regime Label
- Trend-quality Composites
- Trendline
- Triangular MA
- UHL Adaptive MA
- Ultimate Smoother
- Vertical Horizontal Filter
- VIDYA
- Volume-adjusted MA
- Vortex
- VWMA
- Weinstein Stage Analysis
- Whittaker–Henderson Smoother
- Windowed FIR Smoothing
- WMA
- ZLEMA

