SMA & EMA
5-point simple and exponential moving average for a mini price series.
About this calculator
SMA(5) is a plain equal-weight average of all five prices (line 15), so every price moves it by the same fraction of its own change regardless of position in the series — Price t-4 (the oldest) and Price t (the newest) carry identical weight. EMA(5) is different, and not in the way a quick skim of the formula suggests: the loop starts by setting `let ema = p[0]` (line 17) and only applies the smoothing factor alpha from the second price onward (line 19), so the oldest price, Price t-4, is seeded in at full weight rather than being discounted by alpha the way every later price is. The result is that Price t-4 actually carries more influence on EMA(5) than Price t-3, the second-oldest price — (1−α)⁴ = 0.1296 for Price t-4's effective weight at the default α=0.4, versus α(1−α)³ = 0.0864 for Price t-3 — breaking the usual expectation that an EMA's weight decreases monotonically the further back a price sits.
Price t (the newest) still carries the single largest weight, α = 0.4, as a standard EMA would predict. Alpha itself never touches SMA(5) at all — that average doesn't reference alpha anywhere in its formula (line 15). What this does not account for: any minimum or maximum bound on price inputs beyond the UI's 0-to-1e12 range, and it treats all five prices as equally spaced in time, which real tick-by-tick or irregularly sampled price data may not be.
Inputs
Results
SMA(5)
10.44
How to Use This Calculator
- Enter five consecutive price observations from oldest (t-4) to newest (t).
- Adjust the EMA smoothing factor -- higher values weight recent prices more heavily.
- Compare the SMA (equal-weight average) with the EMA (exponentially weighted) to see how the smoothing factor affects trend detection.
How the result changes with Price t-1
| Price t-1 | SMA(5) |
|---|---|
| 5.4 | 9.36 |
| 8.1 | 9.9 |
| 16 | 11.48 |
| 27 | 13.68 |
What each input means
- Price t-4
- Oldest observation.
- Price t-3
- Second-oldest price observation in the series.
- Price t-2
- Middle price observation in the five-point series.
- Price t-1
- Second-most-recent price observation.
- Price t
- Latest observation.
- EMA smoothing
- Higher = more weight on latest price.
How this is calculated
Formula
SMA(n) = Σ(prices) / n | EMA = α × Price + (1 − α) × Previous EMAEngine last updated . Checked against 1 independently-derived test — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.
Frequently Asked Questions
Does Price t-4, the oldest price, really carry more weight in EMA(5) than Price t-3?
Yes, and it comes from how the recursion is seeded rather than from the standard EMA formula. The loop sets `ema = p[0]` before any smoothing is applied (line 17), so Price t-4 enters at full weight; every later price, starting with Price t-3, gets discounted by (1 − alpha) for each step still ahead of it. At the default alpha of 0.4, that makes Price t-4's effective weight 0.1296 versus Price t-3's 0.0864 — the oldest price outweighs the second-oldest.
Does raising the EMA smoothing factor (alpha) change SMA(5)?
No — SMA(5) is a plain average of all five prices (line 15) that never references alpha anywhere in its formula. Alpha only shapes EMA(5), where a higher value shifts more weight onto Price t (the newest observation) and less onto the earlier prices in the recursive blend.
Which single price moves EMA(5) the most at the calculator's defaults?
Price t, the newest observation, at the calculator's default alpha of 0.4 — it receives the recursion's last smoothing weight, alpha itself (0.4), directly and undiscounted, versus Price t-4's seeded weight of (1 − alpha)⁴ = 0.1296. That is not true for every alpha, though: Price t's weight is alpha while Price t-4's is (1 − alpha)⁴, and those two cross around alpha ≈ 0.2755. Below that (e.g. the smallest selectable alpha, 0.05), Price t-4 actually carries more weight than Price t — 0.05 versus 0.95⁴ = 0.8145.
Why would SMA(5) and EMA(5) show different numbers for the same five prices?
SMA(5) treats all five prices identically regardless of order, so it simply reports the flat average; EMA(5) weights recent prices more heavily through the recursive blend (line 19), except for the oldest price's outsized seed weight noted above. Whenever the series is trending rather than flat, that different weighting makes EMA(5) diverge from SMA(5) — more so as alpha rises.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Moving Average Calculator
Calculate Simple Moving Average (SMA), Exponential Moving Average (EMA), Cumulative Moving Average (CMA), and Weighted Moving Average from a series of data points.
Supply ChainDemand Forecast Calculator
Forecast demand using moving average, weighted MA, and exponential smoothing.
Data ScienceA/B Test Calculator
Determine statistical significance of A/B test results. Calculate z-score, p-value, conversion lift, and whether your variant beats the control at your chosen confidence level.
Data ScienceClustering Quality Score Calculator
Evaluate clustering quality using silhouette score, Calinski-Harabasz index, Davies-Bouldin index, and Dunn index from cluster distance metrics.
More in Math & Statistics.