Moving Average Calculator

Compute SMA and EMA for any data series — stocks, prices, or any time series.

MA Moving Average Calculator
Data Values (comma or line separated)
Period (n)

MA What is a Moving Average?

A moving average (MA) is a statistical technique that calculates the average of a sliding window of data points over a time series. As new data arrives, the window moves forward — the oldest value drops out and the newest enters. The result is a smoother curve that filters out short-term noise and highlights the underlying trend.

Moving averages are among the most widely used tools in technical analysis of financial markets. Traders use the 20-day, 50-day, and 200-day moving averages to identify support and resistance levels, trend direction, and potential reversal points. When a shorter-period MA crosses above a longer-period MA (a “golden cross”), it is interpreted as a bullish signal; the opposite (a “death cross”) is bearish.

The two most common types are the Simple Moving Average (SMA) — which gives equal weight to every data point in the window — and the Exponential Moving Average (EMA) — which gives more weight to recent values via an exponentially decaying multiplier. SMA is simpler and more stable; EMA is more responsive to recent price changes but also noisier.

Beyond finance, moving averages appear everywhere: smoothing COVID case counts, sensor noise reduction in engineering, demand forecasting in supply chain, and signal processing in audio and image analysis. Any time you have noisy time-series data and want to see the trend, a moving average is the first tool to reach for.

📐 Formulas

SMA(n) = (Pt + Pt-1 + … + Pt-n+1) ÷ n
Pt = price (or value) at time t
n = period (number of values in the window)
Example: Prices = [10, 12, 11, 13, 14], period = 3 → SMA values: (10+12+11)/3=11, (12+11+13)/3=12, (11+13+14)/3=12.67
EMAt = k × Pt + (1 − k) × EMAt-1
k = smoothing factor = 2 / (n + 1)  ·  Seed: EMA0 = SMA of first n values
Example (n=3, k=0.5): Prices [10, 12, 11, 13, 14]. Seed = (10+12+11)/3 = 11. EMA after 13: 0.5×13 + 0.5×11 = 12. EMA after 14: 0.5×14 + 0.5×12 = 13

📖 How to Use This Calculator

Steps

1
Select SMA or EMA using the tabs at the top. SMA for equal-weight averaging; EMA for recency-weighted.
2
Enter your data in the textarea — oldest values first, newest last. Separate by commas or new lines. Paste from a spreadsheet column works perfectly.
3
Set the period (e.g., 10 for a 10-day MA). For EMA, optionally set a custom k value.
4
Click Calculate. Results show the latest MA, the previous MA (for trend direction), the average of all MA values (SMA mode) or the k factor (EMA mode), and the total count of MA values computed.

💡 Example Calculations

Example 1 — 5-Day SMA of Stock Prices

Closing prices: 44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10, 45.15, 43.61, 44.33

1
Enter all 10 values, set period = 5
2
SMA values: 44.10, 44.20, 44.40, 44.60, 44.60, 44.60 (6 total)
Latest SMA(5) ≈ 44.60. Trend: Flat. The price series shows a modest upward then sideways move.
Try this example →

Example 2 — 3-Period EMA

Values: 10, 12, 11, 13, 14, 12, 15. Period = 3.

1
k = 2/(3+1) = 0.5. Seed (SMA of first 3) = (10+12+11)/3 = 11
2
EMA after 13: 0.5×13 + 0.5×11 = 12. After 14: 0.5×14 + 0.5×12 = 13. After 12: 0.5×12 + 0.5×13 = 12.5. After 15: 0.5×15 + 0.5×12.5 = 13.75
Latest EMA(3) = 13.75. Trend: Rising. EMA reacted to the final 15 value quickly.
Try this example →

Example 3 — 20-Day SMA for Trend Identification

20 monthly sales figures: 100, 105, 98, 110, 115, 108, 120, 125, 118, 130, 135, 128, 140, 145, 138, 150, 155, 148, 160, 165

1
Enter all 20 values, set period = 20. You get 1 SMA value (the average of all 20).
2
Average of 20 values = (100+105+…+165)/20 = 2598/20 = 129.9
SMA(20) = 129.9. With the current value of 165 above the 20-period MA, the trend is strongly bullish.
Try this example →

Example 4 — Custom Smoothing Factor EMA

Values: 50, 52, 51, 55, 58, 56, 60. Period = 5, k = 0.3 (custom, slower than default 2/6=0.333)

1
Seed = SMA of first 5 = (50+52+51+55+58)/5 = 53.2
2
EMA after 56: 0.3×56 + 0.7×53.2 = 54.04. EMA after 60: 0.3×60 + 0.7×54.04 = 55.83
Latest EMA = 55.83 with custom k=0.3. A lower k gives a smoother, slower-reacting EMA.
Try this example →

Frequently Asked Questions

What is a Simple Moving Average (SMA)?
A Simple Moving Average is the unweighted mean of the last n data points. SMA(10) of closing prices = average of the 10 most recent closing prices. As new data arrives, the oldest point drops out and the newest one enters. SMA smooths out short-term noise to reveal the underlying trend direction.
What is an Exponential Moving Average (EMA)?
EMA assigns exponentially decreasing weights to older data points. Formula: EMA_today = k × Price_today + (1−k) × EMA_yesterday, where k = 2/(period+1) is the smoothing factor. Unlike SMA, EMA reacts faster to recent price changes, making it more responsive but also more sensitive to noise.
What is the difference between SMA and EMA?
SMA weights all periods equally; EMA weights recent periods more heavily. EMA responds faster to price changes (less lag) but can generate more false signals. SMA is smoother and better at identifying long-term trends. Common strategies use both: a fast EMA (e.g., 12-day) crossing above a slow SMA (e.g., 26-day) signals a potential buy.
What period should I use for a moving average?
Common periods: 5-day or 10-day for short-term trading; 20-day or 50-day for medium-term trend following; 200-day for long-term trend analysis. There is no universally correct period — it depends on your data's volatility and your time horizon. Many traders use the 20-day, 50-day, and 200-day MAs together to see multiple trend layers.
How is the EMA smoothing factor (k) calculated?
The standard smoothing factor is k = 2 / (period + 1). For a 10-period EMA: k = 2/11 ≈ 0.1818. This means today's price contributes about 18.18% to the new EMA, while the previous EMA contributes 81.82%. You can override k in this calculator for custom weighting.
What does a rising vs falling moving average mean?
A rising moving average (latest MA > previous MA) indicates the data series has been trending upward over the selected period. A falling MA indicates a downward trend. When price is above its moving average, it is considered in an uptrend; below, a downtrend. Moving average crossovers are widely used as trend-change signals.
How do I calculate a 20-day SMA for stocks?
Collect the last 20 closing prices (or more, if you want a full series of SMA values). Enter them into this calculator, set period = 20, and select SMA mode. The latest SMA value is the simple average of the 20 most recent prices. If you have 30 prices, you get 11 SMA values (one for each window position).
Can I use moving averages for data other than stock prices?
Yes. Moving averages work on any time-ordered numerical data: sales revenue, website traffic, temperature readings, energy consumption, sports performance metrics, or any measurement taken at regular intervals. The math is identical — enter your data series, set the window period, and interpret the trend the same way.
What is the MACD indicator?
MACD (Moving Average Convergence Divergence) = EMA(12) − EMA(26) of closing prices. A signal line is a 9-day EMA of the MACD itself. When MACD crosses above the signal line it suggests bullish momentum; below suggests bearish. MACD is one of the most widely used technical indicators and is built entirely from EMAs.
Why does EMA need a seed value?
EMA is calculated recursively — each value depends on the previous EMA. Since there is no 'previous EMA' for the very first calculation, a seed is needed. The standard approach seeds the EMA with the SMA of the first `period` values (the arithmetic average of the first window of data). This calculator uses this standard seeding method.