
Moving averages are one of the most widely used tools in data analysis, finance, and statistics. Whether you are tracking stock prices, monitoring sales trends, or smoothing out noisy sensor readings, a moving average helps reveal the underlying direction of your data by filtering out short-term fluctuations.
The concept is straightforward: instead of plotting each individual data point, you calculate the average of a defined window of values and slide that window forward through time. The result is a smoother line that makes patterns and trends far easier to identify.
Despite its simplicity, the moving average is remarkably powerful. It forms the foundation of more advanced techniques in time series analysis and technical analysis, and it appears across fields as diverse as economics, engineering, and public health.
The simple moving average is the most straightforward type. It calculates the arithmetic mean of a fixed number of consecutive data points, then slides that window forward by one period at a time.
Formula:
Where:
Example: If you are tracking daily temperatures over a week and want a 3-day SMA, you average days 1–3, then days 2–4, then days 3–5, and so on.
The SMA treats every value in the window equally, which makes it easy to interpret and calculate. The trade-off is that it reacts slowly to sudden changes in the data, since an old value carries the same weight as the most recent one right up until it drops out of the window entirely.
The weighted moving average addresses one of the SMA’s limitations by assigning greater weight to more recent data points. Older values still contribute to the average, but they matter less than newer ones.
Formula:
Where:
Example: For a 3-period WMA, you might assign weights of 1, 2, and 3 to the oldest, middle, and most recent values respectively. The denominator becomes 1+2+3=6.
The WMA responds more quickly to recent price or value changes than the SMA, making it useful when timeliness matters more than stability.
The exponential moving average is the most widely used type in financial analysis and time series forecasting. Like the WMA, it gives more weight to recent data — but rather than dropping off abruptly at the window boundary, it applies a smoothing factor that causes older values to decay exponentially. This means every past observation technically still influences the current average, though its contribution diminishes rapidly over time.
Formula:
Where:
Example: For a 10-period EMA, the smoothing factor is . Each new EMA value is calculated by blending the current observation with the previous EMA using this factor.
The EMA reacts faster to recent changes than either the SMA or WMA, which makes it popular in fast-moving environments such as stock trading. The downside is that it is slightly more complex to calculate and can be more sensitive to short-term volatility.
The cumulative moving average, sometimes called the running average, calculates the mean of all data points from the beginning of the dataset up to and including the current observation. The window is not fixed — it expands with every new data point.
Formula:
Or equivalently, using a recursive form:
Where:
Example: If you are tracking cumulative average customer satisfaction scores as survey responses come in, the CMA updates after every new response to reflect the overall mean to date.
The CMA is best used when you want a long-run perspective on your data and are less concerned with detecting recent shifts. Because the window grows continuously, each new observation has a diminishing effect on the average — meaning the CMA becomes increasingly resistant to change over time.
While each type of moving average has its own calculation, the simple moving average formula serves as the foundation from which all others are built. Understanding how to calculate it manually — and how the formula adapts across different types — gives you a solid basis for applying moving averages correctly in practice.
The simple moving average formula calculates the arithmetic mean of n consecutive data points within a sliding window:
Where:
The window shifts forward by one period at a time, so the oldest value is dropped and the newest value is added with each step.
Suppose you have the following 8 daily sales figures (in units):
| Day | Sales |
|---|---|
| 1 | 120 |
| 2 | 135 |
| 3 | 128 |
| 4 | 142 |
| 5 | 155 |
| 6 | 148 |
| 7 | 160 |
| 8 | 172 |
Using a 3-day simple moving average ():
The full results table:
| Day | Sales | 3-Day SMA |
|---|---|---|
| 1 | 120 | — |
| 2 | 135 | — |
| 3 | 128 | 127.67 |
| 4 | 142 | 135.00 |
| 5 | 155 | 141.67 |
| 6 | 148 | 148.33 |
| 7 | 160 | 154.33 |
| 8 | 172 | 160.00 |
Notice that the first two days have no SMA value. With a window of , you need at least 3 data points before the first average can be calculated. This is referred to as the lag period, and it equals periods.
The core SMA formula extends naturally into the other moving average types:
Weighted Moving Average (WMA)
Weights are assigned in ascending order — the most recent observation receives the highest weight. A common linear weighting scheme for uses weights of 1, 2, 3, giving a denominator of 6.
Exponential Moving Average (EMA)
The EMA formula is recursive: each value depends on the one before it. The first EMA value is typically seeded using the SMA of the first observations.
Cumulative Moving Average (CMA)
The CMA uses an expanding window, so the denominator t grows with every new observation rather than staying fixed at .
The window size n is the single most important parameter in any moving average formula. It controls the trade-off between smoothness and responsiveness:
There is no universally correct window size. The right choice depends on the nature of your data, the frequency of your observations, and whether you are trying to identify short-term signals or long-term direction.
Understanding the mechanics behind a moving average — not just the formula, but the logic of what it does to your data — is essential for using it well. At its core, a moving average works by continuously recalculating the average of a fixed (or expanding) window of values as it slides through a dataset from left to right. Each recalculation produces a single smoothed data point, and the sequence of those points forms the moving average line.
The defining characteristic of a moving average is the sliding window. Rather than computing a single average for the entire dataset, the window isolates a subset of consecutive observations, calculates their mean, and then advances one period forward — dropping the oldest value and picking up the newest one.
Using the same 8-day sales dataset from the previous section:
With a 3-day window, the sliding process looks like this:
| Step | Window | Calculation | SMA |
|---|---|---|---|
| 1 | Days 1–3 | (120 + 135 + 128) ÷ 3 | 127.67 |
| 2 | Days 2–4 | (135 + 128 + 142) ÷ 3 | 135.00 |
| 3 | Days 3–5 | (128 + 142 + 155) ÷ 3 | 141.67 |
| 4 | Days 4–6 | (142 + 155 + 148) ÷ 3 | 148.33 |
| 5 | Days 5–7 | (155 + 148 + 160) ÷ 3 | 154.33 |
| 6 | Days 6–8 | (148 + 160 + 172) ÷ 3 | 160.00 |
With each step, one value exits the left side of the window and one enters from the right. This is what makes the average “moving” — the window is not recalculated from scratch each time so much as it is updated incrementally as new data arrives.
Raw data is rarely perfectly clean. Daily sales figures fluctuate due to weekday effects. Stock prices jump on news events. Temperature readings vary due to measurement error. These short-term movements are often noise — random variation that obscures the true underlying trend.
When a moving average is applied, these fluctuations are averaged out across the window. A single unusually high or low value has less impact on the moving average than it does on the raw data, because its influence is diluted by the other values in the window. The result is a smoother line that better represents the general direction of the data.
Consider what happens when an outlier appears on Day 6 in the sales data — say, sales drop sharply to 90 instead of 148:
The outlier still affects the moving average — it cannot be ignored entirely — but its impact is spread across two or three periods rather than appearing as a dramatic single-point spike. Once the outlier exits the window, the average recovers naturally.
One of the most important properties of a moving average is lag — the delay between when a change occurs in the raw data and when the moving average reflects that change.
Lag arises because the moving average incorporates past values. When a trend reverses or a sharp move occurs, the moving average continues to reflect the old data still sitting inside the window. The more periods in the window, the greater the lag.
Using the sales dataset, if sales suddenly accelerate from Day 6 onward:
| Day | Sales | 3-Day SMA | 5-Day SMA |
|---|---|---|---|
| 5 | 155 | 141.67 | — |
| 6 | 148 | 148.33 | 141.60 |
| 7 | 160 | 154.33 | 146.60 |
| 8 | 172 | 160.00 | 156.60 |
The 5-day SMA lags further behind the raw data than the 3-day SMA. This illustrates the core trade-off: a longer window produces a smoother line but responds more slowly; a shorter window is more responsive but noisier.
Lag is not a flaw — it is an inherent property of any backward-looking average. Recognising it helps you avoid misreading a moving average as a real-time signal when it is always, by definition, a historical one.
The relationship between the raw data line and the moving average line carries useful information:
These crossover signals work because moving averages with different window sizes reflect different time horizons. The shorter one tracks recent momentum; the longer one tracks the broader trend. When they diverge or converge, it suggests that the short-term behaviour of the data is beginning to diverge from its longer-run direction.
By default, most moving averages are trailing (also called lagging): the average at time t is calculated from the current and past values. This is the standard approach for real-time applications, since future values are not yet known.
In some analytical contexts — particularly when working with historical datasets — a centred moving average is used instead. Here, the window is positioned symmetrically around the current point, incorporating both past and future values relative to :
Centred moving averages eliminate lag entirely for historical analysis, since the average is placed at the true midpoint of the window. They are commonly used in seasonal decomposition of time series data. However, they cannot be used for forecasting or real-time monitoring, since they require values from the future relative to the point being smoothed.
The most well-known application of moving averages is in financial markets, where they are used to analyse price trends and generate trading signals.
Traders and analysts apply moving averages to stock prices, exchange rates, commodity prices, and index values to distinguish sustained trends from short-term volatility. The most commonly used configurations are the 20-day, 50-day, and 200-day moving averages, which represent short-, medium-, and long-term trend perspectives respectively.
Key applications in finance include:
The exponential moving average is particularly favoured in trading because of its faster response to recent price changes, reducing the lag that can make the SMA slow to signal reversals.
Economists and business analysts use moving averages to smooth out irregular fluctuations in economic data and identify meaningful trends in indicators such as GDP growth, inflation, unemployment, and retail sales.
Because many economic time series contain seasonality — regular patterns that repeat on a monthly or quarterly cycle — moving averages are used to produce seasonally adjusted figures. A 12-month moving average of monthly data, for example, averages out one full year of seasonal effects, revealing the underlying economic trend more clearly.
In business settings, moving averages are applied to:
Moving averages became widely familiar to the general public during the COVID-19 pandemic, when 7-day rolling averages of case counts, hospitalisations, and deaths were used in dashboards and news reporting worldwide.
In public health, raw daily figures for infectious disease are often unreliable on a day-to-day basis due to reporting delays, weekend lags in test processing, and administrative backlogs. A 7-day moving average smooths these artefacts and gives a cleaner picture of whether transmission is genuinely rising or falling.
Broader applications in epidemiology include:
In engineering and electronics, moving averages function as a type of low-pass filter — a filter that allows slow-moving (low-frequency) signals to pass through while attenuating rapid (high-frequency) fluctuations.
This makes them valuable in any application where sensor data or measurement signals contain noise:
The EMA is especially well-suited to real-time signal processing because it is computationally efficient — it requires only the current input value and the previous EMA, rather than storing an entire window of past values.
Weather and climate data are inherently variable, with day-to-day fluctuations that can make it difficult to detect underlying patterns. Moving averages are routinely used to reveal longer-term trends in:
In sports performance analysis, moving averages are used to track athlete and team performance over time, controlling for the natural game-to-game variation that makes single-match statistics unreliable.
Applications include:
Digital analysts use moving averages to monitor and interpret website traffic, conversion rates, and campaign performance metrics — all of which tend to exhibit strong day-of-week seasonality that can obscure real trends.
A 7-day moving average of daily website sessions, for example, removes the weekly cycle (high traffic on weekdays, lower on weekends) and makes it easier to assess whether overall traffic is genuinely growing or declining. Common applications include:

The arithmetic mean is the most familiar summary statistic. It divides the sum of all values in a dataset by the total number of observations, producing a single number that represents the entire dataset.
The key distinction is scope. The arithmetic mean collapses the entire dataset into one static value. A moving average, by contrast, produces a series of values — one for each position of the sliding window. This makes the moving average far better suited to datasets where values change over time, because it preserves the temporal structure of the data rather than flattening it.
| Arithmetic mean | Moving average | |
|---|---|---|
| Output | Single value | Series of values |
| Captures trends | No | Yes |
| Sensitive to outliers | Yes | Partially |
| Use case | Static datasets | Time series data |
For a deeper review of the arithmetic mean, see Khan Academy: Mean, median, and mode.
A weighted average assigns different levels of importance to different observations before computing the mean. Each value is multiplied by a weight, and the results are summed and divided by the total weight.
The weighted average is a static measure — like the arithmetic mean, it produces a single summary value for the entire dataset. A weighted moving average (WMA), however, applies the weighting logic within a sliding window, combining the adaptability of a moving average with the emphasis of weighting. This makes the WMA more responsive to recent data than a simple moving average, while still tracking change over time rather than producing a fixed summary.
For more on weighted averages, see Math is Fun: Weighted Mean.
The median is the middle value in a sorted dataset. It is resistant to outliers in a way the arithmetic mean is not — a single extreme value cannot pull the median far from the centre of the distribution.
A moving median (also called a rolling median) applies this same logic within a sliding window, making it a robust alternative to the simple moving average when data contains frequent spikes or anomalies. In financial data, for example, a flash crash might create an extreme outlier that distorts a moving average for several periods — a moving median would be less affected.
The trade-off is computational cost. Recalculating a median within a sliding window is more expensive than recalculating a mean, which makes moving medians less common in real-time applications despite their robustness.
| Moving average | Moving median | |
|---|---|---|
| Calculation | Mean of window | Median of window |
| Outlier resistance | Moderate | High |
| Computational cost | Low | Higher |
| Common use | Trend analysis | Robust smoothing |
For more on the median and its properties, see Stat Trek: Mean, Median, Mode.
It is worth distinguishing the exponential moving average (EMA) from both the simple arithmetic mean and the simple moving average, as it is sometimes confused with both.
The EMA is particularly favoured in signal processing and financial analysis for this reason — it reacts quickly to new data while retaining some memory of past behaviour.
For a practical guide to the EMA and how it differs from the SMA, see Investopedia: Exponential Moving Average (EMA).
The cumulative average (also called the running mean) is the mean of all observations from the beginning of a dataset up to the current point. Like the moving average, it updates as new data arrives — but unlike a fixed-window moving average, it never drops old values.
The cumulative average is useful for tracking long-run central tendency, but it becomes increasingly slow to respond to change over time. As t grows, each new observation has a smaller and smaller influence on the cumulative average. A moving average avoids this by keeping the window size fixed, ensuring that recent observations always receive consistent weight.
| Moving average | Cumulative average | |
|---|---|---|
| Window | Fixed | Expanding |
| Responds to recent change | Yes | Decreasingly |
| Best for | Trend tracking | Long-run mean |
| Drops old data | Yes | No |