Indicator library · Trend
Moving Averages, Simple, Exponential, Weighted
The oldest tool in technical analysis and the component most others are built from. It makes one modest claim, the mean of the last n closes is this number, and almost everything attributed to it is an additional claim that has to be argued separately.
The three forms
All three answer the same question (what has the price been, on average, recently), and differ only in how they distribute the weight across the window.
Simple (SMA)
SMA = (sum of the last n closes) ÷ n. Every close in the window counts equally, and every close outside it counts not at all. That produces a property worth understanding before using one: the average can move sharply on a quiet day, because a large value has just left the back of the window. The line is reacting to something that happened n bars ago, not to today.
Exponential (EMA)
EMA = previous + k × (close − previous), where k = 2 ÷ (n + 1). No value ever fully leaves; each one decays. The line responds faster to new information and never jumps because of an exit from the window. Two cautions: the constant is written differently by different authors, Wilder's smoothing and Swenlin's PMO both use 2 ÷ n instead, and because the whole history is carried forward, an EMA's value depends on how much data it was given.
Weighted (WMA)
A linear ramp: the most recent close is multiplied by n, the one before by n − 1, and so on, divided by the sum of the weights. It sits between the other two and is the least used of the three, largely because the EMA achieves a similar effect with one line of arithmetic.
The practical difference between them is smaller than the amount written about it. On ordinary data an SMA(20) and an EMA(20) track within a fraction of a per cent of each other most of the time, and they separate exactly when it matters least, during sharp moves, when everything is late anyway.
Lag is the whole trade-off
Every property of a moving average follows from one fact: it is a summary of the past, so it cannot turn until enough of the past has changed. A ten-period average needs several new closes before it acknowledges a reversal; a fifty-period average needs many more. This is not a flaw that better settings fix, and any indicator built from averages (MACD, Bollinger Bands, most trend systems) inherits it whole.
What settings buy is a position on a single axis. Short windows turn early and often, producing more signals of which a larger share are wrong. Long windows turn late and rarely, producing fewer signals of which a larger share are right, each arriving after a meaningful part of the move. There is no setting that is early and reliable, and a backtest that appears to have found one has usually found a period that happened to trend.
The readings that get used
Slope
The least fragile thing here. A rising average means the recent mean is higher than it was, which is a fact rather than an inference. Used as a filter, only take long setups while the average rises, it removes a great deal of counter-trend trading at the cost of missing every turn.
Price relative to the average
Above or below is a statement about where the current close sits against its own recent mean. Its usefulness depends entirely on the instrument's behaviour: in a trending stock price spends long stretches on one side, and in a mean-reverting one it crosses constantly. The same rule therefore produces opposite results on two instruments for reasons that have nothing to do with the rule.
Crossovers
Two averages of different lengths changing places. Widely used, widely backtested, and almost entirely dependent on trend persistence in the test period. Treat any published crossover statistic as a description of the sample rather than of the method.
What the window exit looks like
The most counter-intuitive property of a simple average is worth seeing in numbers rather than describing. Below are five consecutive sessions from the series above, showing the close that entered the ten-period window, the close that left it, and what the average did.
| Bar | Close entering | Close leaving | SMA 10 |
|---|---|---|---|
| 16 | 39.6 | 33.1 | 36.19 |
| 17 | 38.6 | 32.5 | 36.80 |
| 18 | 37.2 | 33.9 | 37.13 |
| 19 | 35.8 | 35.0 | 37.21 |
| 20 | 36.5 | 34.4 | 37.42 |
Each step of the average is the difference between those two numbers divided by ten, and nothing else. When the close leaving the window is much lower than the one entering, the line rises even on a session where price fell, and the reverse. An analyst who reads a turn in a simple average as news about today has read something that happened ten bars ago, which is the strongest practical argument for the exponential form.
Choosing a length
There is no optimal window, only a position on one axis, and the honest way to pick a spot on it is to start from how long you intend to hold.
| Window | Behaviour |
|---|---|
| 5–10 | Tracks price closely, turns within days, crosses constantly in a range. Useful as a filter, poor as a signal. |
| 20–21 | Roughly a month of sessions. The shortest window that behaves like a trend measure rather than a smoothed price. |
| 50 | About a quarter. Widely plotted, so it carries some coordination effect; slow enough to ignore most single-week noise. |
| 200 | Nine to ten months, not a year. The most watched line in the market and the slowest to acknowledge anything. |
Two lengths a long way apart behave differently for structural reasons; two lengths close together, a 48 against a 50, differ only by noise, and any test that prefers one over the other has measured the sample rather than the method.
Where it misleads
| Situation | What goes wrong |
|---|---|
| Sideways market | Two averages of the same prices cross repeatedly around one level. Structural, not a settings problem. |
| Window exit (SMA) | A large value leaving the back of the window moves the line on a quiet day, the average reacts to n bars ago, not today. |
| Round-number reverence | The 200-day works through coordination, not statistics. Nothing distinguishes it from the 190-day except how many people watch it. |
| Unadjusted prices | A split leaves a step in the series, and every average spanning it is meaningless until the window clears. |
| Short EMA history | An exponential average carries its whole history; started too recently, its value depends on where the data begins. |
| Comparing lengths across instruments | Twenty periods is twenty sessions on a daily chart and twenty minutes on an intraday one. The number is not a duration. |
What volume adds
A moving average weights by recency and ignores participation entirely: a close made on the year's heaviest volume counts exactly as much as one made on its lightest. That is the specific gap, and it is why a crossover confirmed by expanding volume is a different observation from the same crossover on the thinnest session of the month.
The direct fix is to weight by volume instead of by recency, which is what VWAP does, an average in which a heavily traded price counts for more because more of the market agreed to it. It answers a genuinely different question from any of the three forms above, and on a volume-based site it is the more natural default.
Frequently asked questions
What does a moving average actually claim?
Only that the average of the last n closes is a particular number. That is a weaker statement than it is usually treated as: it contains no forecast, no fair value and no support level. Everything else attributed to moving averages, that price "respects" the 200-day, that a crossover signals a trend change. Is an empirical claim laid on top of the arithmetic, and each one has to earn its keep separately.
Simple, exponential or weighted: which should I use?
They differ only in how the n closes are weighted, and the difference is smaller than the debate around it. A simple average weights every close equally, which means a large move leaving the window moves the average as much as a large move entering it, the reason a simple average can turn while nothing is happening today. Exponential and weighted averages front-load recent data, so they turn sooner and whipsaw more. Choose by whether you would rather be early and wrong more often, or late and wrong less often; there is no third option.
Why is the 200-day average treated as special?
Because a great many participants watch it, not because 200 has any statistical property. It is roughly a trading year, it appears by default on most platforms, and institutions cite it in commentary, so orders cluster near it and it acquires real behaviour from being watched. That makes it worth knowing about and does not make it predictive; the mechanism is coordination, and it applies just as much to the 50-day and just as little to the 137-day.
Do crossovers work?
In sustained trends, usually; in ranges, almost never, and no setting fixes that, because the problem is structural. Both lines are averages of the same prices, so when there is no trend for them to lag behind they cross repeatedly around the same level. Any published crossover result depends almost entirely on how much of the test period was trending, which is why the same system looks excellent on one decade and useless on the next.
How do I choose the length?
From the holding period you intend, not from a backtest. The window sets how much has to change before the line acknowledges it, so a length is really a statement about how long a move must persist before you are willing to act on it. Someone holding for weeks has no use for a five-period average, and someone trading within the day has no use for a two-hundred-period one. Choosing the number this way gives you something to defend afterwards; choosing it by testing values until one looks good gives you a curve fit and no reason.
Should the average be plotted on the close, the open, or the typical price?
The close by convention, and it is the right default because the close is the price at which the session was settled and the one most participants reference. An average of the typical price — high, low and close divided by three — is slightly steadier and perfectly defensible. What matters far more than the choice is being consistent: comparing your average of the close against a chart drawn from typical prices will produce small persistent differences that look like errors and are not.
Do moving averages act as support and resistance?
Sometimes, through coordination rather than through any property of the arithmetic. A widely watched average has orders clustered around it because many participants are watching the same line, and clustered orders produce the behaviour that gets described as support. The mechanism is the number of eyes, not the mean, which is why the effect is stronger on the 50 and 200 than on lengths nobody plots, and why it is unreliable everywhere.
Can I use a moving average to smooth an indicator rather than a price?
Yes, and it is done constantly, the signal line on MACD, the %D line on a stochastic and the smoothing inside RSI are all averages of an indicator rather than of a price. The caution is that each layer adds its own lag, and an average of an average of a price is a long way from the market. Two layers is common and defensible; three should make you ask what the third is buying.
What length is one trading year?
About 252 sessions in the American market, which is why 200 is often described as roughly a year and is not. Two hundred sessions is closer to nine and a half months. This is a small point with a large consequence for anyone testing calendar claims: a 200-day average and a one-year average are different windows, and results attributed to one are frequently measured on the other.