Moving Average (SMA) Calculator

Compute simple moving averages for any time series data. Visualize original values and smoothed trend on an interactive canvas.

Enter numbers (integers or decimals) separated by commas, spaces, or new lines. Period must be ≥ 1 and ≤ number of data points.
? Stock prices (5 days): 150,152,149,153,155,157,156,158,160,162
?️ Daily temps: 12,14,15,13,17,19,21,20,18,15
? Weekly sales: 34,42,40,48,55,52,60,68,74,70
? Sine wave (noise): 1.2, 1.8, 2.4, 2.9, 3.1, 2.8, 2.2, 1.5, 1.1, 0.8
? Linear trend: 5,7,9,11,13,15,17,19,21,23
Privacy first: All calculations are performed locally. The chart is drawn in your browser – no data leaves your device.

What is a Simple Moving Average (SMA)?

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).

Historical Development

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).

Why Use an Interactive SMA Calculator?

  • Visual understanding: See how the smoothed line lags behind the original data, and how the period affects smoothness.
  • Educational aid: Ideal for teaching time series, statistics, or technical analysis.
  • Quick analysis: Paste your data, choose window, and instantly see the moving average and key stats.
  • Explore scenarios: Test different window sizes to find the right balance between sensitivity and smoothness.

Mathematical Foundation

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ᵢ−μ)² ].

Step‑by‑Step Calculation

  1. Enter a sequence of numbers (separated by commas, spaces, or new lines). Example: 5, 7, 9, 11, 13.
  2. Specify the period (window size), e.g., 3.
  3. Click "Calculate & Draw". The tool computes the moving average using a sliding window.
  4. The chart displays original data (blue) and the moving average (red). Summary statistics appear below.

Examples for Different Window Sizes

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
Case Study: 50‑Day vs 200‑Day Moving Average in Stock Trading

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.

Choosing the Right Period

There is no single "best" period – it depends on your goal:

  • Short period (e.g., 3‑5): Reacts quickly to changes, but may be noisy.
  • Long period (e.g., 20‑200): Smoother, identifies major trends, but lags significantly.
  • Domain conventions: Finance often uses 10, 20, 50, 200 days; meteorology may use 7 or 30 days for temperature.

Common Misconceptions About Moving Averages

  • Moving average predicts future: No, it only smooths past data; it is a lagging indicator.
  • Larger window is always better: Not necessarily – excessive smoothing hides important turning points.
  • Moving average removes all noise: It reduces but does not eliminate randomness; it's not a perfect filter.
  • SMA equals weighted moving average: No, SMA gives equal weight to all points; weighted or exponential gives more weight to recent data.

Applications Across Fields

  • Finance: Identify support/resistance levels, generate trading signals (moving average crossovers).
  • Economics: Smooth GDP, unemployment or inflation data to reveal cycles.
  • Engineering: Noise reduction in sensor readings (e.g., temperature, pressure).
  • Epidemiology: Smooth daily case counts to see underlying trends.

Trusted methodology – The moving average algorithm follows standard statistical definitions (NIST Handbook, 2023). The chart rendering uses adaptive scaling for clarity. Reviewed by the GetZenQuery data science team, last updated March 2026. All calculations are double‑precision accurate.

Frequently Asked Questions

Simple Moving Average (SMA) gives equal weight to each data point in the window. Exponential Moving Average (EMA) gives more weight to recent observations, making it more responsive to new information.

With period=1, the moving average equals the original data series (since average of one number is the number itself).

Absolutely. The calculator accepts any real numbers (including negatives). All calculations preserve floating‑point precision.

Because a moving average with period k produces only n−k+1 points. The line starts at index k‑1 (0‑based) and ends at the last index.

Currently we focus on Simple Moving Average (SMA). For other variants, see our EMA Calculator or WMA Calculator (separate tools).

The input should be a continuous series. If you have missing data, you need to impute or clean it before using. The calculator will warn if any non‑numeric entries are detected.
References: NIST Engineering Statistics Handbook – Moving Average; Murphy, J.J. "Technical Analysis of the Financial Markets" (1999); Wikipedia: Moving average.