Moving Average
Updated · Sources checked
A simple moving average adds a fixed number of recent observations and divides by that count. Each new value enters the window as the oldest leaves. State the input, interval, adjustment method, and missing-data rule, because they affect the result. The calculation summarizes past values and does not forecast a price.
Key points
- An SMA gives equal weight to a fixed number of observations.
- The bar interval defines what one period means.
- Document missing observations, adjustments, and rounding.
- A moving average summarizes past values rather than forecasting a price.
What a simple moving average shows
A simple moving average (SMA) is the arithmetic mean of a fixed number of recent observations, recalculated as each new observation arrives. In a price chart, state the input and interval; the line smooths past values rather than forecasting a price.
The NIST/SEMATECH handbook describes a moving average as a smoothing method that averages successive smaller sets of values and drops the oldest value as the window advances. In a chart, a 10-period SMA means 10 selected observations, not necessarily 10 calendar days. The bar interval determines what one period means.
Moving averages are one tool within technical analysis. A line can help compare a price series with its own recent average, but the comparison is descriptive. A price crossing the line does not establish that a rise or decline will continue.
Calculate the average step by step
To calculate an SMA, add the selected observations and divide by their count. Each new value enters the window as the oldest leaves, and every included observation receives equal weight.
For a 3-period average of closes $10, $12, and $14, add them to get $36 and divide by 3. The SMA is $12. When the next close is $17, remove $10 and calculate ($12 + $14 + $17) / 3, which is $14.33 when rounded to cents.
The general formula is: SMA at time t equals the sum of the current observation and the prior N minus 1 observations, divided by N. Keep full precision during the calculation and round only when displaying the result. If prices have more decimals than cents, early rounding can slightly change later values.
A weighted moving average uses weights that differ across observations, while an exponential moving average gives greater weight to recent data through a smoothing parameter. These are not the same formula as an SMA. If two chart services show different values, compare the method, input, bar interval, and rounding before assuming one is incorrect.
Choose the window and interval deliberately
The window length determines how many observations enter the calculation. A shorter window changes more with each new value, while a longer window smooths more variation and responds more slowly.
There is no universally correct period for every chart or question. Choosing a window because it makes a past chart look persuasive risks tailoring the explanation to the outcome. State the period before comparing examples, and explain why that window answers the descriptive question being asked.
Also state the bar interval. A 20-period SMA calculated from hourly bars covers 20 hourly observations, while a 20-period SMA calculated from daily bars covers 20 daily observations. The same number of periods can describe very different stretches of time.
When comparing two averages, write each length and input clearly, such as a 5-day SMA of adjusted closes and a 20-day SMA of adjusted closes. A stock research checklist can help separate a chart description from a business analysis based on filings and operating results.
Handle missing bars and corporate actions
Decide how the series treats a missing observation before calculating the average. Whether the window uses the last N available bars or another documented rule affects which values are included.
Do not replace a missing price with zero unless zero is truly the observation. A zero can drag an average sharply lower and misrepresent an absent bar. If the source does not explain its missing-data treatment, mark the resulting average as uncertain rather than guessing at the provider's method.
Corporate actions can make historical prices appear discontinuous if earlier observations and later observations use different share bases. In a fictional split example, state the event date and adjustment arithmetic. For example, assume a 2-for-1 split after Day 3 and divide earlier synthetic prices by two to express them on the later share basis.
That assumption is only a consistent arithmetic convention for the invented example. Real data providers may label adjusted and unadjusted series differently, and a reader should consult the provider's documentation and company filings before interpreting an actual historical chart. A commodity contract series can have separate expiry and roll effects; see commodity exposure mechanics before treating a continuous futures chart as one uninterrupted contract.
Compare two ways to handle a missing close
Look at how the source defines its window when a scheduled closing price is missing. A window of the last three available observations can produce a different result from a window that requires prices for three consecutive sessions.
Example (fictional) A daily record lists closing prices in USD of $48 Monday and $51 Tuesday, with no observation for a scheduled Wednesday session. Thursday closes at $54. Averaging the last three available closes gives ($48 + $51 + $54) divided by three, or $51. A strict window covering Tuesday through Thursday has only two observations and produces no full-window average under that rule.
Suppose a third source documents that it copies forward the last value on missing days. Its modeled Wednesday value would be $51. The average for Tuesday through Thursday is then ($51 + $51 + $54) divided by three, or $52. Label the copied value and the method in the notes before comparing the average with either of the others.
For another window, such as 5 observations, at least 5 valid input values are needed before a full SMA is available. Do not fill the early part of a chart with partial averages unless the chart clearly labels them as partial. Otherwise, two series may look comparable even though the averages use different numbers of observations.
Read the line without treating it as a signal
An SMA lags the values it summarizes because it includes past observations. A sudden change affects the average as it enters the window and older values leave, which says nothing about the next price.
Statements such as “the price crossed the average” should identify which price field was used and whether the comparison occurred at an intraday point or at a completed close. A temporary move through the line and a close above it are different observations. A vague description can turn into an untestable claim.
If the purpose is to compare a rule on historical data, write the rule before viewing later observations. Include every qualifying event and every non-event, and distinguish a chart value from an assumed order fill. The SEC's order types bulletin explains that an order can execute at a price different from the last-traded price, or a limit order may not execute.
Short-term trading can result in rapid losses, as the SEC explains in its day-trading risk discussion. A moving average does not remove that risk. It is a summary of prior values, not a guarantee, a tested recommendation, or an individualized investment decision.
Document the calculation so another reader can repeat it
A clear note names the input, interval, window length, source, adjustment, and rounding convention. Record delays or historical revisions when comparing charting tools.
For a worksheet, retain the observations included in the first average and the observations that enter and leave on each update. This makes it easier to find an off-by-one error, an unintended partial window, or a mismatched adjusted-price series. It also shows exactly what the moving average does and does not summarize.
For context on chart methods, see the technical analysis overview; for long-term business evidence, compare the company's reports through fundamental analysis. The fictional quote and volume simulator can illustrate how specified inputs affect a made-up series. None of those resources selects an investment or predicts a price.
As of December 2026, NIST's cited handbook supports the fixed-window arithmetic described here. The examples use fictional inputs, and no strategy or trading result was tested. If a chart provider changes how it handles adjustments or missing periods, check its documentation before comparing old and new values.
Frequently asked questions
How do you calculate a simple moving average?
Add the observations in a fixed-size window and divide by their count. When a new value arrives, remove the oldest value and recalculate.
What does a 20-period moving average mean?
It averages 20 observations, and the bar interval determines how much time those observations cover. Twenty hourly bars and twenty daily bars represent different periods.
Why do moving-average values differ between chart tools?
Tools may use different inputs, windows, adjustments, missing-bar rules, or rounding. Compare those settings before treating the values as inconsistent.
Does a moving average predict price direction?
No. It smooths prior observations and responds as new values enter and old values leave the window. It cannot guarantee a later price movement.
How should a split be handled in an example?
State the assumed event date and adjustment calculation. In this page’s synthetic example, earlier prices are divided by two after an assumed 2-for-1 split.
Related guides
Sources
- 6.4.2.1. Single Moving Average · NIST/SEMATECH
- Understanding Order Types: Investor Bulletin · SEC Investor.gov
- Thinking of Day Trading? Know the Risks. · SEC Investor.gov
What changed
- 2026-12-03 · Expanded the SMA formula, window choices, missing-data handling, synthetic adjustment, and calculation example.