534 / 736MA

Moving average

Rolling average

The latest price has fallen, but its average is still rising. That need not be an error. Here is how moving averages are calculated, why they differ, and what their lines actually show.

A Moving average condenses a series of prices into a value that is recalculated as new data arrives. Joining those values produces a line that smooths individual fluctuations and makes longer-term developments easier to read. There are several ways to calculate it; none knows the next price by itself.

Petr adds a Moving average to his chart and notices that his friend's line looks different. They compare settings first. TradingView offers SMA, a simple average, and EMA, an exponential average that gives newer data more weight, among other types. The input matters too: Close is a candle's closing price, High its highest price. Averaging highs answers a different question from averaging closes, even if the lines look similar. [1]

With an SMA, the window of selected prices moves: a new value enters and the oldest drops out. This is how TradingView describes it. An EMA, Fidelity explains, instead combines the new price with the previous result. Older prices are carried forward with a gradually diminishing influence. The same length setting therefore does not give both calculations the same memory. An EMA also depends on the starting value from which its calculation began. [1] [3]

Petr sees a lower latest price, yet the SMA points upward. There is no contradiction: the simple average described by Fidelity covers the whole selected window. As it moves, both the incoming and the outgoing prices matter. If the new price replaces an even lower old value, the average can rise. The calculation below illustrates exactly this situation; the average's direction does not describe only the latest price step. [2]

Petr lengthens the period and the line becomes calmer. Fidelity notes that greater smoothing in an SMA comes with more lag. An EMA of comparable length gives more emphasis to new prices, but greater sensitivity can also bring more short-term changes. A faster line is not automatically more accurate. The choice determines which movements stand out; it does not remove uncertainty about what the market will do next. [2] [3]

Petr switches from an hourly chart to a daily one, and the average tells a different story. TradingView calls the interval represented by a candle its Timeframe. With the same number of values, the calculation now covers a much longer stretch. Read the average's length alongside its timeframe and check for gaps in the data. A count of available observations cannot simply be assumed to equal that many calendar days. [4]

Until a candle closes, its Close can change. TradingView explains this feature of live data; if the average uses that input, its newest point moves too. Petr may therefore see the price cross the line during the interval, only for the crossing to disappear before the end. A rule based on completed closes must wait for a completed close, or it would be evaluating a different situation. [5]

TradingView can shift a Moving average forward or backward on the chart using Offset. This changes where the result appears, not when its inputs became known. A line drawn ahead of the current price does not, by itself, forecast the future. In a historical test, Petr must check whether the necessary data would already have been available at the time of his decision. [1]

Some traders use touches or crossings of a Moving average as a reason to consider a trade. That still leaves exits, position size, achievable prices and costs unspecified. TradingView also discusses overfitting in strategy testing: tuning a rule to the accidents of a particular history. Petr therefore needs precise rules and a test on separate data. A calculated line is not a fixed price barrier, and an attractive past result does not guarantee future profit. [6]

Example · MA

Price down, average up

Take fictional closing prices from completed candles: 100000, 100020 and 100040 USD/BTC. Their SMA is (100000 + 100020 + 100040) / 3 = 100020 USD/BTC. The next candle closes at 100030 USD/BTC. The oldest value drops out, and the new window gives (100020 + 100040 + 100030) / 3 = 100030 USD/BTC. The latest price fell compared with its predecessor, but it replaced an even lower old price in the average. That is why the average rose. These are illustrative numbers, not a current quote or a trading recommendation.

For the clearest picture, read this entry together with Technical indicator, Simple moving average, Exponential moving average, Moving average crossover, Timeframe, Backtesting. The reverse links also lead from Technical analysis, Timeframe, Technical indicator, Simple moving average.

01Do SMA and EMA with the same length give the same result?

Not in general. SMA gives equal weight to values in its selected window, while EMA gives newer prices more weight and builds on its previous result. How the calculation starts matters too. Coinciding at a particular point does not mean the methods calculate the same thing.

02Can I rely on the price bouncing off the average?

No. A moving average is calculated from data, not guaranteed price support. To study bounces, first define what counts as a bounce, when you would enter and exit, and what costs would apply. Only then can the rule be tested, still without certainty about future results.

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