Blog/Technical Analysis
Technical AnalysisOct 3, 202611 min read

Simple Moving Average (SMA): Formula, Periods and How It Differs From the EMA

The simple moving average is the plain average of the last n closes. The formula with a worked 5-period example, how the period length sets the lag, a simple moving average vs exponential moving average table, where traders use the 20, 50 and 200 SMA, and what an SMA can and cannot tell you.

BL
Benjamin Loh
Founder of SnapPChart · trader and dev

A simple moving average is the least mysterious indicator on your chart. It adds up the last n closes, divides by n, and draws the answer as a line. Every other moving average is a variation on that. It is also the version people argue about, because everything useful and everything annoying about it comes from one fact: every close in the window counts the same. This post is the definition, the arithmetic worked out on real numbers you can check, what the period setting does to lag, a plain SMA vs EMA table, and where the 20, 50 and 200 SMA get used.

Quick Answer

The simple moving average in one paragraph

The simple moving average (SMA) is the average of the last n closing prices: add the n closes and divide by n. Each new bar adds the newest close and drops the oldest, so the line slides along with price. A short period (5 to 20) hugs price and turns quickly. A long period (50 to 200) is smoother and turns late. Unlike the EMA, every close in the window has equal weight, which makes the SMA slower to react and easy to verify by hand. Traders commonly read the 20 SMA as the short-term trend, the 50 SMA as the medium-term trend and the 200 SMA as the long-term trend. An SMA describes past closes. It does not predict the next one.

Everything below is either the arithmetic behind that paragraph or the places it gets misused.

What Is a Simple Moving Average?

A moving average smooths price by replacing each bar with the average of the recent bars. The StockCharts ChartSchool article on simple and exponential moving averages defines the simple version as the average price of a security over a specific number of periods, calculated by summing the closes and dividing by that number. The Wikipedia entry on moving averages describes the same thing in financial use as the unweighted mean of the previous k data points. "Unweighted" is the important word. It means no close in the window is treated as more important than another.

The "n" is the period, and it is the one setting. On a daily chart a 50 SMA averages 50 sessions. On a 5-minute chart a 50 SMA averages 50 five-minute bars, which is a little over four hours of trading. Same name, very different window, so say the period in time before you compare lines.

The SMA is also the plain ingredient behind other indicators. The StockCharts page mentions the 20-day SMA in the context of short-term analysis and Bollinger Bands. This post stays on the average itself. Crossovers between two of them are a separate topic, covered in the golden cross and death cross guide, and the exponential version has its own write-up in the EMA day trading strategy post.

How to Calculate a Simple Moving Average

The simple moving average formula

SMA(n) = (Close 1 + Close 2 + ... + Close n) / n

Here it is on ten hypothetical closes, with a 5-period SMA. The closes are made up so the arithmetic is easy to check, not market data. Day 5 is the first day with five closes, so it is the first day the SMA exists.

Day 5: the window is days 1 to 5, so 50.0 + 50.4 + 51.0 + 50.6 + 51.4 = 253.4, and 253.4 / 5 = 50.68. Day 6: the window slides one bar. Day 1 drops out, day 6 comes in: 50.4 + 51.0 + 50.6 + 51.4 + 52.2 = 255.6, and 255.6 / 5 = 51.12. The table has the rest.

5-period SMA, worked on hypothetical closes
made-up numbers, not market data
DayCloseWindowSum of 5 closesSMA(5)
551.4days 1 to 5253.450.68
652.2days 2 to 6255.651.12
751.8days 3 to 7257.051.40
852.6days 4 to 8258.651.72
953.0days 5 to 9261.052.20
1052.4days 6 to 10262.052.40

You do not have to re-add five numbers every day. The line moves by the new close minus the oldest close, divided by n. Day 6: (52.2 - 50.0) / 5 = 0.44, and 50.68 + 0.44 = 51.12. Day 7: (51.8 - 50.4) / 5 = 0.28, and 51.12 + 0.28 = 51.40. That shortcut is also the first thing worth understanding about the SMA: the line does not move because of today alone. It moves because of the gap between today and the bar that just left.

In a spreadsheet or on a chart

In a spreadsheet it is an AVERAGE over the last n cells, copied down. On a charting platform you add the moving average study, choose the Simple type, set the period, and check that the source is Close, since some platforms let you average the open, high, low or an HLC blend. The first n minus 1 bars have no value because the window is not full yet, which is why a 200 SMA starts 199 bars into your chart history.

Illustrative only: a jump from 100 to 110 with a 5-period and a 20-period SMA

Simple moving average lag diagram: price steps from 100 to 110 and a 5-period SMA catches up much faster than a 20-period SMAForty made-up closes: twenty bars at 100, then twenty bars at 110. The 5-period SMA climbs from 100 to 110 in five bars, rising 2 points per bar. The 20-period SMA climbs 0.5 points per bar and only reaches 110 on the last bar of the chart. The gap between the two lines is the extra lag that comes from a longer period.hypothetical closes and two SMAs100105110bar 21: first close at 110SMA(5) reaches 110 at bar 25SMA(20) still catching upreaches 110 at bar 40closeSMA(5)SMA(20)made-up closes, SMAs computed from them. not market data
Illustrative simple moving average lag: a 5-period SMA reaches a new price level in five bars, a 20-period SMA takes twenty

What Does the Period Length Do to Lag?

The period is a trade-off between smoothness and lateness, and you do not get one without the other. StockCharts puts it this way: a 10-day moving average will hug prices quite closely and turn shortly after prices turn, while a 100-day average contains a lot of past data that slows it down. Its picture is speedboats versus ocean tankers. The Wikipedia entry makes the same point in plain statistics, noting that a simple moving average that is not centered lags behind the latest data point by about half the sample width.

You can see the mechanism with arithmetic instead of adjectives. Take a hypothetical stock that sits at 100 for twenty bars and then closes at 110 on every bar after that. The diagram above plots exactly this. Count the bars since the jump, including the first 110 bar, and the two SMAs catch up like this.

Catching up to a jump from 100 to 110
hypothetical step, not market data
Bars at 110SMA(5)SMA(20)
1 bar102.0100.5
3 bars106.0101.5
5 bars110.0102.5
10 bars110.0105.0
20 bars110.0110.0

Check one cell. After 3 bars at 110, the 5-bar window holds two 100s and three 110s: (200 + 330) / 5 = 106. The 20-bar window holds seventeen 100s and three 110s: (1,700 + 330) / 20 = 101.5. Each new 110 bar moves the SMA(5) by (110 - 100) / 5 = 2 points and the SMA(20) by (110 - 100) / 20 = 0.5 points. That is the entire lag: a bigger n means each new close gets a smaller share of the line, so it takes longer to arrive.

The price of the short period shows up in sideways trading. A fast line crosses back and forth through a choppy range because it follows every wiggle, and each cross looks like a signal. A slow line crosses less, and when it does, more of the move has already happened. Neither is the right setting. What helps is deciding the window you care about, in time, and setting the period to match. On a 5-minute chart, a 20 SMA is about the last hundred minutes. On a daily chart it is about the last four weeks of sessions.

Before you trust the line

Price above the 50 SMA tells you where the average is. It does not tell you whether the pullback you are about to buy is holding.

Upload the screenshot and SnapPChart grades that single image as a momentum continuation setup: structure, levels, EMAs, VWAP and the volume bars in frame, then an entry, a stop with its reasoning, targets and the reward-to-risk they imply. A stretched C-grade chart is still a C.

Grade this chart

Simple Moving Average vs Exponential Moving Average

The only structural difference is the weighting. In an SMA, each of the n closes counts 1/n. In an EMA, the newest close counts the most and older ones fade. StockCharts shows the EMA multiplier as 2 / (n + 1), so a 10-period EMA puts an 18.18% weight on the latest price and a 20-period EMA puts 9.52% on it. Compare that with the SMA, where the latest close in a 20-period window carries 5%. The EMA therefore moves faster toward a new price, which is why StockCharts says EMAs reduce lag, and the SMA is the one that represents a true average of the whole period.

Simple vs exponential moving average
same inputs, different weighting
DimensionSimple (SMA)Exponential (EMA)
How the closes are weightedEqually. In a 20-period SMA every close carries 5%Unequally. The newest close carries the most. StockCharts gives a 20-period EMA a 9.52% weight on the latest price
What the line isThe plain average of the last n closesA running average that leans toward recent closes
Reaction to a sharp moveSlower. The line only fully adjusts once the old closes have rolled out of the windowFaster. StockCharts says EMAs reduce lag by weighting recent prices more
What happens when an old bar leavesA big old bar leaving the window shifts the line by (new close minus oldest close) / n, even if today is quietOld bars fade out gradually instead of dropping out at once
Whipsaw in sideways tradingFewer flips, because the line is smootherMore flips, because the line chases price
Easy to check by hand?Yes. Add n closes, divide by nHarder. It builds on the previous EMA value
Common use casesSlow trend filters and reference levels (StockCharts says SMAs may be better suited to identifying support or resistance)Faster pullback and momentum references

So which is better? It depends on the job, and there is no published evidence in the sources used here that one beats the other for returns. If you want a line that reacts quickly, the EMA is the tool. If you want a calm reference line or a number you can verify by hand, the SMA is. Which EMA settings day traders use, and how to trade a pullback into them, is covered in the EMA day trading strategy guide, so this page does not repeat them. The roundup of indicators for day trading shows where moving averages fit next to volume and momentum tools.

How Do Traders Use the 20, 50 and 200 SMA?

StockCharts groups moving averages by horizon: 5 to 20 periods for short-term trends, 20 to 60 for medium-term and 100 or more for long-term. It calls the 50-day quite popular for the medium-term trend and the 200-day perhaps the most popular long-term average. Those three numbers are the ones you will see on most charts, and they are popular partly because so many people have them on screen.

What each common SMA is usually read for
a reading convention, not a rule that price obeys
20 SMA: short-term trend. On a daily chart, about four weeks of sessionsPASS
50 SMA: medium-term trend. On a daily chart, about ten trading weeksPASS
200 SMA: long-term trend. On a daily chart, about forty trading weeksPASS
Price above a rising SMA is the usual picture of an uptrend on that horizonPASS
Treating a touch of an SMA as a buy signal on its ownWATCH
Comparing a 50 SMA on a 1-minute chart with a 50 SMA on a daily chartWATCH

How to use the SMA indicator without overreading it

The workable use is as a filter and a reference, not an entry button. First, read the slope. A rising SMA with price holding above it describes an uptrend on that timeframe, and a flat SMA with price crossing it repeatedly describes a range. Second, use it as a place to watch. In an established uptrend, traders watch pullbacks toward a rising medium-term average to see whether price holds. The strategy page for the 50-day moving average pullback walks through that setup. Third, keep it in context with structure. The SMA says where the average of recent closes is. It does not know about support, volume, or the news that moved the stock. The support and resistance guide covers the levels a pullback has to hold for the average to matter.

The weekly version has its own tradition. The 30-week average used in stage analysis is a moving average on a weekly chart, and the Stan Weinstein stage analysis post covers how that read works. For crossovers between a faster and a slower SMA, including the 50 and 200 pair, see the golden cross vs death cross guide. Both are left there so this page stays on the average itself.

Where an SMA Misleads, and Reading It on a Screenshot

It lags by construction

StockCharts says it directly: moving averages tend to lag because they are based on past prices, and investors use them to smooth price action and filter out noise. That is the deal. You get a cleaner line and you pay for it in lateness. An SMA turning up after a low is confirming a move that has already started.

Old bars can move it for no reason today

Because the line moves by (new close minus oldest close) / n, a large old candle leaving the window can shift the SMA even on a quiet day. If the line jumps for no obvious reason, look at the bar that just dropped out n bars back before you read it as news.

It is blind to everything except closes

Volume, structure, levels and the trend of higher highs and higher lows are all outside it. Two charts can sit on the same 50 SMA with completely different setups. An SMA is context for a trade, not the trade.

What SnapPChart does and doesn't do with an SMA

The precise version, since this is easy to oversell. SnapPChart reads one chart screenshot you upload. It does not calculate an SMA, and its instructions name EMAs, VWAP, MACD and volume, not the SMA. If you plot a 20, 50 or 200 SMA on the chart before you take the screenshot, the line is in the image, so the grader can read where price sits against it. It never calculates the average and it never detects a cross between two of them. The grade is built on the chart in frame, and the SMA is yours to read with the checks above.

It also trades momentum continuations only: a long is a pullback in an established uptrend, a short is a rally in an established downtrend, and it does not take reversal or counter-trend setups. So an SMA never becomes a signal on its own, and price crossing back through a long average is not something the grader treats as a trade. A neutral description of what a single screenshot read covers is on the AI chart analysis page.

The short version to act on

SMA(n) = the sum of the last n closes divided by n. Each bar drops the oldest close and adds the newest, so the line moves by (new minus oldest) / n. A short period hugs price and flips often. A long period is smooth and late. The SMA weights every close equally and the EMA weights recent closes more, so the EMA reacts faster. The 20, 50 and 200 SMA are read as the short, medium and long-term trend. Read the slope, treat the line as a place to watch, and confirm with structure and volume. It describes the past and never predicts the next close.

Frequently Asked Questions

What does SMA mean in stocks?

SMA stands for simple moving average: the plain average of a stock's last n closing prices, recalculated on every new bar. A 50 SMA on a daily chart is the average of the last 50 daily closes. It is drawn as a single line over the price candles, and it moves because the oldest close drops out of the window as the newest one is added.

How do I calculate a simple moving average in a spreadsheet?

Put the closes in a column, then in the row where you have n closes use the average of the last n cells. For a 5-period SMA with closes in B2 to B6, the formula in C6 is =AVERAGE(B2:B6). Copy it down and the window slides one row at a time. The first n minus 1 rows have no value, because there are not yet n closes to average.

Is a 20 SMA the same as a 20 EMA?

No. Both use 20 closes, but the SMA gives each of them the same weight (5% each), while the EMA gives the newest close more weight and the oldest very little. On a quiet chart the two lines sit close together. After a sharp move the EMA turns first and the SMA follows later, which is the whole difference between them. If your platform lets you pick the type, check which one a setting is using before you compare it with someone else's chart.

Does a longer SMA period make a better signal?

It makes a slower line, which is a different thing. A longer period smooths more and flips direction less often, but it also reacts later, so it tells you about the trend after more of it has already happened. A shorter period reacts sooner and flips more in sideways trading. Neither is better in the abstract. The useful question is which window in time you care about on this chart, and the period is how you set it.

Does SnapPChart read or calculate a simple moving average?

No. SnapPChart reads only the screenshot you upload, and its instructions name EMAs, VWAP, MACD and volume. They do not name an SMA. If you plot a 20, 50 or 200 SMA on the chart before you take the screenshot, the line is in the image and the grader can see where price sits against it, but it never calculates an SMA and it does not detect crosses. It also takes momentum continuation setups only, so an SMA is context for you to read, not a signal it trades.

Disclaimer

This article is for educational and informational purposes only and is not investment, financial or trading advice. The SMA definition, the description of EMA weighting, the horizons for short, medium and long-term averages and the lag comparison are as described by the cited sources (StockCharts ChartSchool and Wikipedia) and are reproduced as their published descriptions, not as rules endorsed here. Every worked example, including the ten-day 5-period SMA table and the 100 to 110 step used for the lag comparison, is a hypothetical construction built so the arithmetic can be checked; none is a real security or session. The diagram is illustrative and computed from made-up closes, not market data. No win rate, success rate or backtest is claimed for any moving average, period or signal, and none is implied. A moving average describes price that has already traded and does not predict direction. Day trading carries a substantial risk of loss and is not suitable for every investor. SnapPChart grades a static chart screenshot you upload and returns a setup grade, entry, stop, targets and reasoning for that single image; it grades momentum continuation setups only, does not calculate a simple moving average or detect crossovers, does not take reversal or counter-trend setups, and does not use live data. Do your own analysis, size positions so that being wrong is survivable, and consider speaking to a licensed financial professional about your own circumstances before trading.

BL
Benjamin Loh
Founder of SnapPChart · trader and dev

Writes about AI-assisted day trading, technical analysis, and the systems traders actually use to stay disciplined.

An SMA shows you where the average is. It does not tell you whether your entry is any good.

Upload the chart screenshot and SnapPChart grades that one image as a momentum continuation setup, reading the structure, levels, EMAs, VWAP and volume bars in frame, then returns a setup grade, an entry, a stop with the reasoning behind its level, targets, and the reward-to-risk they imply. One skipped late entry on an overextended chart covers it.

Grade your setupNo card required