About the Moving Average Calculator (SMA/EMA)
This moving average calculator turns a list of closing prices into the latest simple moving average (SMA) and exponential moving average (EMA) for a short and a long lookback period. Paste prices from your charting platform or broker export, choose the two periods — for example 5 and 10 days, or the classic 50 and 200 — and it shows each average, how far the last price sits above or below it, and the most recent crossover between the short and long SMA.
Traders use moving averages to smooth out noise and judge trend direction: price above a rising average suggests an uptrend, and a short average crossing above a long one (a "golden cross") or below it (a "death cross") is a widely watched signal. Long-term investors use the same lines to see whether a market is trading above or below its longer-run trend.
Enter prices oldest first. The EMA is seeded with the simple average of the first n prices and then updated with a smoothing factor of 2 ÷ (n + 1), which is the convention most charting packages use; values can differ slightly from a platform that seeds the EMA from older data you did not paste.
With the default inputs, the short sma (latest) is 50.36. Change any value above to recalculate instantly.
How to use the moving average calculator (sma/ema)
- 1Export or copy closing prices from your chart, oldest first.
- 2Paste them into the price box.
- 3Set the short and long periods, such as 20 and 50 or 50 and 200.
- 4Read the latest SMA and EMA for each period and the trend reading.
- 5Check the most recent crossover and the chart to see how price moved around the averages.
Formula and method
The simple moving average is the plain mean of the last n closing prices, so every price in the window counts equally and the oldest price drops out as each new one arrives. The exponential moving average weights recent prices more heavily: each new value is α times the latest price plus (1 − α) times the previous EMA, where α = 2 ÷ (n + 1). The first EMA value is seeded with the SMA of the first n prices.
A golden cross is recorded when the short SMA moves from at or below the long SMA to above it; a death cross is the reverse. The calculator scans every point where both averages exist and reports the most recent crossover.
- Pₜ
- Closing price at period t
- n
- Number of periods in the average
- α
- EMA smoothing factor, 2 ÷ (n + 1)
Worked examples
20 daily closes, 5- and 10-day averages
The last five closes (49.1, 50.2, 50.8, 50.4, 51.3) average 50.36 and the last ten average 49.48. The 5-day EMA, seeded at the first five-day mean and updated with α = 1/3, ends at 50.41. The last price of 51.3 is 1.87% above the 5-day SMA and above both averages — a steady uptrend with no crossover.
Falling stock, 3- and 8-day averages
After peaking at 86.2 the stock slid, and on the 9th close the 3-day SMA dropped below the 8-day SMA — a death cross. The latest 3-day SMA is 79.27 versus 81.00 for the 8-day; the last price of 79.40 sits just above the short average but below the long one.
Same prices, 10- and 20-day averages
With exactly 20 prices, the 20-day SMA is the mean of all of them, 47.62, and the 20-day EMA equals it because the EMA is seeded from that same average. The 10-day SMA of 49.48 sits well above it, confirming the uptrend.
Frequently asked questions
What is the difference between SMA and EMA?+
A simple moving average weights every price in the window equally. An exponential moving average gives more weight to recent prices, so it reacts faster to new moves but also produces more false signals in choppy markets.
What are the most common moving average periods?+
Short-term traders often use 9, 10, 20 or 21 periods; swing traders watch 50; and long-term investors focus on the 200-day average. The 50/200-day pair is the classic setup for golden and death crosses.
What is a golden cross and a death cross?+
A golden cross happens when a shorter moving average crosses above a longer one, often read as the start of an uptrend. A death cross is the opposite — the short average crossing below the long one — and is read as bearish. Both are lagging signals.
Why does my EMA differ from my charting platform?+
An EMA depends on where it starts. Platforms usually seed it from many earlier bars you may not have pasted, while this calculator seeds it with the SMA of the first n prices you enter. Paste a longer history and the values converge.
How many prices do I need?+
At least as many as the longest period you choose — 200 prices for a 200-day average. For a stable EMA, paste two to three times the period length so the seed value has little influence on the latest reading.
Results are estimates for educational purposes and are not financial advice. Rates, fees and terms vary — confirm with your lender or a licensed advisor before making decisions.