How it works
An exponential moving average is a recursive smoother. Rather than averaging a fixed window equally, it takes a fraction of the new price and adds it to the remaining fraction of yesterday's average. That single line of arithmetic gives every past observation a weight that decays geometrically: today's bar contributes most, yesterday's slightly less, and bars from long ago fade toward zero without ever being discarded outright.
That last detail is the structural difference from the simple average, and it matters in practice. An SMA changes when an old bar falls out of its window, which produces the odd effect of the line moving because of something that happened N bars ago. An EMA has no window edge, so it never jumps for that reason. What it does instead is respond faster to new information — for the same nominal length it sits closer to price and turns sooner — which is exactly what you want when catching a trend early and exactly what hurts you when the market is choppy.
The smoothing factor is 2/(N+1), a convention chosen so that an EMA of length N has roughly the same centre of mass as an SMA of length N and the two are loosely comparable. Be careful with other smoothings that use the same word: Wilder's averages, which sit inside RSI, ATR and ADX, use a factor of 1/N instead, so a 14-period Wilder average is about as smooth as a 27-period EMA. Confusing the two is a common source of indicator values that refuse to match between platforms.
Traders use EMAs where reaction speed matters more than stability: intraday bias lines, the 8 and 21 pair on short-term charts, the 20 and 50 on swing charts, and as raw material inside other indicators. MACD is nothing but the distance between two EMAs; Keltner Channels are centred on one. If you want an even faster line, the weighted and Hull averages go further down the same road; if you want stability, go back to the SMA. The EMA is the pragmatic middle of that family and the default for most people who look at a chart every day.
Calculation
The arithmetic in words, in the order it happens.
Compute the smoothing factor k = 2 / (N + 1). Each bar's EMA is then k times the current source price plus (1 - k) times the previous bar's EMA. The series is normally seeded with a simple average of the first N values. Expanding the recursion shows the weights: the current bar carries k, the one before it k(1-k), the one before that k(1-k) squared, and so on, so influence decays geometrically and never reaches exactly zero.
Source
An AlgoBeamScript implementation of the formula above, written by us from the arithmetic so the code and the calculation agree line for line.
Runs unchanged on the platform and in the AlgoBeamTS runtime. The language reference is in the documentation.
Inputs
Defaults are the values most charting packages ship with. They are conventions, not optimal settings — the right length depends on your instrument and your holding period.
| Input | Default | What it changes |
|---|---|---|
| Length | 20 | Sets the smoothing factor through k = 2/(N+1). Short lengths such as 8 or 9 track price closely and are used for intraday bias; 20 and 50 are the standard swing lines; 100 and 200 behave as slow regime filters. |
| Source | Close | The price fed into the recursion. Close is standard; a typical price built from high, low and close damps the effect of erratic closing prints without lengthening the average. |
| Offset | 0 | Displaces the plotted line in time. It changes nothing about the calculation and is used mainly to keep the line clear of the bar that is currently forming. |
How to read it
What practitioners take from the plot. Read these as descriptions of market state, not as entry signals.
- Price holding above a rising EMA on pullbacks
- A trend with organised participation. Because the EMA sits closer to price than an equivalent SMA, repeated shallow touches suggest buyers are stepping in quickly rather than waiting for deep discounts.
- Fast EMA crossing above slow EMA
- Short-term average trade has overtaken longer-term average trade. Earlier than the equivalent SMA cross, and correspondingly more likely to be reversed within a few bars.
- EMA slope flattening while price still rises
- The rate of advance is falling even though price has not turned. Usually the first mechanical sign that a trend is maturing rather than accelerating.
- Price crossing and re-crossing within a few bars
- Range conditions. The EMA’s speed advantage becomes a liability here; either lengthen it or stand aside until slope reappears.
Limitations
Where this indicator misleads. None of these are fixed by a better parameter.
- It still lags. Weighting the recent past more heavily reduces delay but cannot remove it, and at a turning point the EMA is behind price by construction.
- The extra responsiveness produces more false signals in sideways markets than a simple average of the same length. Speed and reliability move in opposite directions and no length setting escapes that.
- A single large gap moves the line immediately and permanently, because the recursion has no way to discard an observation — it can only let it decay.
- The word exponential is used loosely across platforms. A tool using Wilder’s 1/N smoothing plots a visibly slower line for the same length, so values copied between systems often disagree.
Educational reference. This page explains how an indicator is built and how it is commonly read. It is not investment advice, not a recommendation and not a signal service. No indicator is profitable on its own — each is a way of describing a market, and any rule built on one has to be tested with realistic costs before it is traded.