About the Moving Average Calculator (SMA & EMA)
Calculate a simple (SMA) or exponential (EMA) moving average from your own prices. Paste closing prices or load a CSV export, choose the period, and see the average for every bar, how far the last close is above or below it, and a chart of both.
Moving averages smooth out day-to-day noise so the direction of the price is easier to see. The 20, 50 and 200-bar averages are the ones most often watched on daily charts.
How it works
A simple moving average is the plain average of the last n closes. A 20-day SMA adds up the latest 20 closes and divides by 20; the next day the oldest close drops out and the newest comes in.
An exponential moving average gives more weight to recent prices. It starts from the simple average of the first n closes, then each new close moves it a fraction of the way towards the price: 2 ÷ (n + 1) of the gap, so about 9.5% a bar for a 20-bar EMA. Platforms differ in how they start an EMA (some begin from the first price instead of an average), but the difference fades away after a few dozen bars.
Because the EMA reacts faster, it turns sooner after a change in direction, while the SMA is steadier. On a price that rises by the same amount each bar, both settle at the same distance behind it: (n − 1) ÷ 2 bars' worth.
Assumptions and limits
- Prices must be in date order, oldest first; dated files listed newest first are reordered automatically.
- The first value appears on the nth bar; an EMA computed from a short history can differ slightly from a platform with years of data.
- The page uses closing prices; to average highs, lows or other values, paste those numbers instead.
Worked examples
A 3-bar SMA
Closes 1, 2, 3, 4, 5 give a 3-bar SMA of 2, 3 and 4 on the last three bars.
A 3-bar EMA after a jump
Three closes of 10 then one of 16: the EMA moves halfway to 13, while the SMA is 12.
Price versus its average
If the last close is 1.0910 and the 20-bar SMA is 1.0850, the price is 0.55% above its average.
How to use the Moving Average Calculator (SMA & EMA)
- Paste your price history. Closes oldest first, or a CSV file from your platform.
- Choose SMA or EMA. And the number of bars to average.
- Read the average. The last value, a chart and every bar.
Frequently asked questions
What is the difference between SMA and EMA?
An SMA weights every bar in the period equally. An EMA gives the newest prices the most weight, so it follows the price more closely and turns sooner, at the cost of reacting more to short-lived moves.
How do I calculate a 20-day moving average?
Add the last 20 closing prices and divide by 20. Each day, drop the oldest close and add the newest to get the next value. Paste your prices here and the page does it for every day at once.
Which moving average period should I use?
Short averages such as 9 or 20 bars follow the price closely; 50 bars shows the medium-term trend and 200 the long-term one. Many traders watch two together and look at which side of them the price is on.
Why is my EMA slightly different from my trading platform?
An EMA depends on every earlier price, starting from its first value. With only a short history the starting point still has an effect; with a few hundred bars the values match the platform's to the displayed decimals.
Can I download the results?
Yes. The Download button saves every bar with its close and moving average as a CSV file you can open in Excel or Google Sheets, or load back into your charting software.
This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.