536 / 736EMA

Exponential moving average

Exponentially weighted moving average

An EMA gives fresh prices more influence while gradually fading older history. Here is how a new point grows out of the previous result, and why two correctly calculated lines can still differ.

An Exponential moving average, or EMA, gives more weight to newer prices. On a chart, it helps readers follow price developments through a smoother line. Each new value combines the current price with the previous result. It therefore usually responds to changes faster than a Simple moving average, or SMA, while still relying on prices already available.

After each time interval, shown as a candle on the chart, Petr records its last price. Instead of adding all the values again, he can take the previous EMA and move it part of the distance towards that price. This is how Fidelity explains the method. TradingView expresses the same calculation as a weighted new price plus a weighted previous EMA. This is called recursion: the next step uses the result of the last one. [1] [2]

A coefficient, a number setting the new price's weight, determines that fraction. TradingView gives the common relationship 2 / (N + 1), where N is the selected length. A higher N gives the new input less weight and slows the adjustment. Petr therefore needs more than the label EMA: he needs the length setting and the coefficient convention. Length controls how the weights are assigned; the example below shows one step in numbers. [3]

At the very beginning, Petr has no previous EMA. Fidelity describes starting with an SMA, the ordinary average of the initial prices. Choosing that starting result is called initialization. If another tool starts differently or loads a different amount of history, the lines can differ even with identical subsequent prices. The difference gradually fades with further calculations; the name EMA alone therefore does not guarantee identical values. [1]

The previous EMA already carries older price information. Each new step reduces its influence again, as TradingView explains. This is why the method is called exponential: with a fixed coefficient, the influence of an original value fades through repeated multiplication by the same factor. The selected length therefore does not define a fixed set of recent prices beyond which everything disappears, as in an SMA. A very small influence is also not exactly zero in the mathematical description. At length 1 under the coefficient convention above, the exception is simple: the EMA equals the new price and the previous result has no weight. [3]

Petr switches from an SMA to an EMA, and with the same period the line usually follows new prices more closely. Fidelity points to both sides of this sensitivity: an earlier response and more frequent short-term changes. In a market without a clear direction, Petr may therefore see a string of quick reversals. A trading rule must also account for the costs of these trades. Proximity to the price alone does not measure the quality of his decisions. [1]

Petr compares his chart with a friend's. In TradingView, Source selects the input, such as Close, the candle's last price. Timeframe sets the indicator's data interval, which can differ from the displayed chart's interval. Before calling a difference an error, they compare the market, data provider, input price, interval and handling of missing values. Comparing the calculation itself makes sense only once the inputs match. [2] [4]

On a live chart, the newest EMA moves with the price. TradingView explains that an open candle's Close is a continually updated value, not its final close. An EMA using it changes too, as can a crossing. Petr therefore needs to distinguish a rule evaluated during the interval from one that waits for its close. A historical test cannot treat the final price as information he already knew earlier. [5]

Petr can calculate an EMA, but that does not yet specify when or how to trade. In its strategy documentation, TradingView separates a signal, order creation and actual filling. Petr also needs exit rules, timing and costs. Watch for overfitting too: tuning rules to the accidents of a past chart. Testing on separate data without further adjustment helps reveal this weakness; even an exact calculation cannot promise a future outcome. [6]

Example · EMA

The same price, but a different starting point

For an illustrative fictional calculation, choose a coefficient of 0.5, corresponding to length 3 under 2 / (N + 1). The previous EMA is 100000 USD/BTC and the new price is 100040 USD/BTC. We get 0.5 × 100040 + 0.5 × 100000 = 100020 USD/BTC. A second calculation has the same new price but a previous EMA of 100010 USD/BTC: 0.5 × 100040 + 0.5 × 100010 = 100025 USD/BTC. The original difference of 10 USD/BTC shrank to 5 USD/BTC, but did not disappear. This is how a difference in starting values can gradually fade. The numbers illustrate the method, not a current market or an instruction to trade.

For the clearest picture, read this entry together with Moving average, Simple moving average, Moving average crossover, Timeframe, MACD, Backtesting. The reverse links also lead from Moving average, Simple moving average, Moving average crossover, Relative Strength Index.

01Does an EMA use only the selected number of latest prices?

Not as a finite window like an SMA. The previous EMA also carries the fading influence of older history. The selected length normally sets the coefficient, not a cutoff where the past suddenly ends. Reproducing an exact result also requires knowing how it was initialized.

02Is a faster EMA always better than an SMA?

It depends on what you want to observe. A more sensitive line can show a change sooner, but may also reverse more often during brief fluctuations. For a trading rule, assess the whole process, including fills and costs, on data that was not used for tuning too. Speed alone is not evidence of an advantage.

DOC · 001Fidelity — EMADocumentation DOC · 002TradingView — EMADocumentation DOC · 003TradingView — Moving averagesDocumentation DOC · 004TradingView — MTFDocumentation DOC · 005TradingView — RepaintingDocumentation DOC · 006TradingView — StrategiesDocumentation
Revised: Source-first · No investment advice