Compute simple moving averages for any time series data. Visualize original values and smoothed trend on an interactive canvas.
A simple moving average is one of the most common statistical smoothing techniques. It calculates the average of a fixed number (window) of consecutive data points, then "moves" the window forward one step. SMA is widely used in finance to identify trends, in meteorology to smooth daily temperatures, and in manufacturing to monitor quality.
SMA at position t (window size n):
SMAₜ = (xₜ₋ₙ₊₁ + xₜ₋ₙ₊₂ + ... + xₜ) / n
Where the average is taken over the last n observations up to time t (right‑aligned).
The concept of moving averages dates back to the early 20th century, used by statisticians to smooth time series. In the 1920s, the moving average became a cornerstone of technical analysis in stock markets, popularized by Charles Dow and later by technicians like Robert Rhea. Today, moving averages are embedded in every trading platform and are a fundamental tool in statistical process control (Shewhart charts).
Given a sequence x₁, x₂, …, xₙ and window size k (1 ≤ k ≤ n), the simple moving average produces a new sequence of length n−k+1:
SMAᵢ = (xᵢ + xᵢ₊₁ + … + xᵢ₊ₖ₋₁) / k , for i = 1 … n−k+1
In this calculator, we align the moving average with the last value of the window (right-aligned), which is the conventional representation in finance. For example, with data [1,2,3,4,5] and k=3, SMA = [ (1+2+3)/3=2, (2+3+4)/3=3, (3+4+5)/3=4 ] and we plot these at positions 3,4,5 (x‑axis indices 2,3,4 in zero‑based).
The mean of the original data is μ = (1/n)∑xᵢ, and the sample standard deviation is s = √[ (1/(n-1))∑(xᵢ−μ)² ].
All examples are pre‑loaded via the preset buttons and reflect real‑time calculation.
| Dataset (example) | Period (k) | First SMA value | Last SMA value | Interpretation |
|---|---|---|---|---|
| Stock: 150,152,149,153,155,157,156,158,160,162 | 5 | 151.8 | 158.6 | Upward trend confirmed |
| Temperatures: 12,14,15,13,17,19,21,20,18,15 | 3 | 13.67 | 17.67 | Late warm spell |
| Sales: 34,42,40,48,55,52,60,68,74,70 | 4 | 41.0 | 68.0 | Strong growth then plateau |
| Linear trend: 5,7,9,11,13,15,17,19,21,23 | 2 | 6.0 | 22.0 | Moving average also linear |
Traders often watch the crossover of short‑term (e.g., 50‑day) and long‑term (200‑day) moving averages. When the 50‑day SMA crosses above the 200‑day SMA, it's called a "golden cross" – a bullish signal. Conversely, a "death cross" occurs when the 50‑day falls below the 200‑day. Our calculator lets you simulate this with any price series. For instance, using the preset stock data with period 5 (short) and a hypothetical period 10 (long), you could see crossovers. This tool simplifies such exploratory analysis.
There is no single "best" period – it depends on your goal: