535 / 736SMA

Simple moving average

Simple rolling mean

An SMA is an ordinary average whose calculation moves forward as new prices arrive. A simple example explains equal weights, old prices leaving the window, and why missing data is not zero.

A Simple moving average, or SMA, adds selected values and divides their sum by their count. On a price chart, the repeated results form a line that makes developments easier to read without every small fluctuation. To understand it, we need to know the prices used, the window length and the calculation’s timeframe.

Jana writes down the closing prices of some candles and wants a concise summary. The SMA described by Fidelity is an ordinary arithmetic mean: add the prices and divide by their count. Each included price has equal weight. A candle with heavy trading volume therefore does not dominate just because of its volume. Changing the weights according to volume would create a different kind of average. [1]

Jana wants a view of constant length, not an average of the entire history. When a new price arrives, she removes the oldest. TradingView describes this as the SMA's moving window. The change in the result is determined by the difference between the incoming and outgoing values, divided by the window length. The average can therefore change even when the latest price has not moved from the previous one. The example below shows how. [2]

In TradingView, Source selects the input price. An SMA of Close, the candle's closing price, can differ from one of High, its highest price. Timeframe sets the indicator's data interval, which need not always match the displayed chart's interval. Jana therefore records the market, length and that interval too. The number of observations alone does not tell her how many calendar days the calculation covers. [2] [5]

At the start of Jana's record, there are not yet enough prices to fill the chosen window. The definition of an average means she must decide how to handle that: leave the result unavailable for now, or explicitly use a shorter window. Silently inserting zeros is not the answer. A zero price is a real numerical value that lowers the average, not a label meaning “unknown”. Gaps within the series need the same distinction. [1]

An unusually high price enters the record. In an SMA it has the same weight as every other price, but its size lifts the average. Its contribution remains while it is in the window and disappears when it leaves. Jana can therefore see the line's slope change because an old spike has dropped out, rather than because the market has just moved sharply. This follows from the calculation; it is not additional information. [2]

Jana extends the period and short fluctuations become less prominent. Fidelity notes that a longer SMA generally smooths more but also lags the source prices more. It is a choice about how much short-term movement to suppress. Finding the prettiest line on an old chart does not by itself show that the setting will capture future movement better; those future prices have not entered the average yet. [1]

Jana watches a live chart and the newest SMA point moves. TradingView explains that an open candle's Close is not yet its final price: it changes with incoming updates. An average that includes this input changes too. A rule based on completed closes must therefore evaluate completed data. A temporary crossing during a candle may not survive to its end. [3]

The price has crossed above the SMA. What does that mean for Jana? Only a precise rule can specify entry, exit, position size and costs. TradingView distinguishes order creation from filling and warns about overfitting, or fitting rules to the accidents of a particular history. The rule also needs testing on separate data without further tuning. A crossing alone does not establish a trade that could actually be executed or would be profitable. [4]

Example · SMA

The price stayed still; the average did not

Take fictional closing prices from completed candles: 100000, 100030 and 100060 USD/BTC. Their average is (100000 + 100030 + 100060) / 3 = 100030 USD/BTC. The next candle again closes at 100060 USD/BTC. The oldest price leaves, so the calculation becomes (100030 + 100060 + 100060) / 3 = 100050 USD/BTC. The SMA rose by 20 USD/BTC even though the latest price stayed the same. The higher incoming value replaced a lower old one. This illustrates the calculation, not a trading return or current market data.

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

01Does the latest price get more weight in an SMA?

No. All included prices have equal weight in a full window. The newest price changes the result by replacing the oldest, not by having special weight. Other methods, such as EMA, give newer prices more emphasis.

02Can I enter zero for a missing price?

Not without changing the meaning. Zero says the price was zero, not that a record is missing. Decide whether insufficient data means no result or a clearly identified shorter window, and check how your tool handles gaps. Otherwise, you may be comparing averages calculated in different ways.

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