Calculators · Trend

Moving Average Calculator, Step by Step

Three averages of one series, computed side by side. The point is not any single number but the gap between them: how much faster the exponential form turns, how long a seed keeps influencing it, and where a platform disagreement comes from.

Moving average calculator

The sample is the thirty-close series used throughout the moving-average literature to verify implementations; a 10-period simple average of it reaches 22.22 on the tenth bar and 22.21 on the eleventh. If your platform reproduces those two figures, its simple average is right and any remaining disagreement is in the smoothing.

Enter prices and press Calculate.

How far the exponential average leads the simple oneTwo stacked panels sharing one horizontal axis. The upper panel is the thirty closes of the sample series, rising from about 22.1 to a peak near 24.1 before falling back. The lower panel is a histogram of the ten-period exponential average minus the ten-period simple average: it is close to zero while prices drift, turns sharply positive during the rise as the exponential average leads, and turns negative as prices fall back.CLOSEEMA − SMA-0.22widest gap -0.28How far the exponential average leads the simple oneTwo stacked panels sharing one horizontal axis. The upper panel is the thirty closes of the sample series, rising from about 22.1 to a peak near 24.1 before falling back. The lower panel is a histogram of the ten-period exponential average minus the ten-period simple average: it is close to zero while prices drift, turns sharply positive during the rise as the exponential average leads, and turns negative as prices fall back.CLOSEEMA − SMA-0.22widest gap -0.28
Fig. 1: computed from the sample series aboveBoth averages describe the same thirty closes, so every bar of this histogram is disagreement about the past rather than about the future. It sits near zero while price drifts sideways, opens up as soon as the series moves decisively, and crosses back through zero after the turn, later than the price high and earlier than the simple average admits. That lag difference is the entire practical distinction between the two forms, and it is worth measuring on your own data rather than accepting as a rule of thumb.

The three forms, in the order they were invented

Every moving average answers one question (what has this series been doing lately), and the three standard forms differ only in how much they care about lately.

  1. Simple. Add the last n closes and divide by n. Every bar in the window carries the same weight, and when a bar leaves the window it is gone completely. The calculation is (P₁ + P₂ + … + Pₙ) ÷ n, and its one property worth remembering is that the average moves when the bar entering and the bar leaving differ, which means a simple average can turn down on a day the price rose, purely because a large value dropped out of the back of the window.
  2. Weighted. Multiply each bar in the window by its position, so the most recent close counts n times and the oldest counts once, then divide by the sum of the weights: (n·P₁ + (n−1)·P₂ + … + 1·Pₙ) ÷ (n(n+1)/2). It responds faster than the simple form and still forgets a bar entirely once it leaves the window.
  3. Exponential. Take the previous average and pull it towards the newest close by a fixed fraction: EMA = (P × k) + (previous × (1 − k)), with k = 2 ÷ (n + 1). There is no window. Every past bar keeps a weight that shrinks but never reaches zero, which is what makes this form both the most responsive and the hardest to reproduce exactly.

Why the exponential form is the one that causes arguments

Two of the three are arithmetic on a fixed set of numbers, so two implementations either agree or one of them has a bug. The exponential form is recursive, which introduces two choices that no formula settles.

The smoothing constant

The conventional multiplier is 2 ÷ (n + 1), so a 10-period exponential average moves 18.2 per cent of the way to each new close. Wilder’s smoothing, which appears inside RSI and ATR, uses 1 ÷ n instead, 10 per cent for the same period, roughly half as responsive. Both are called exponential averages and a chart labelled "EMA(14)" can mean either.

The seed

The recursion needs a first value. The usual choice is a simple average of the first n closes, but seeding with the first close alone is also common, and some platforms begin the recursion at the very start of the available history rather than at the nth bar. Because the influence of the seed decays rather than ending, that choice is still visible in the numbers dozens of bars later, which is why the honest answer to "my EMA doesn’t match" is usually "how much history did each of you give it?".

What the difference between the three looks like

Behaviour of the three forms, same period
PropertySimpleWeightedExponential
Weight on the newest close1 ÷ n, the same as every other barHighest in the window, tapering linearlyk = 2 ÷ (n + 1), by far the largest single weight
When a bar leavesDropped completely, the average can move for that reason aloneDropped completely, but it was already the lightestNever leaves; its weight decays without reaching zero
Reproducible from a price listExactlyExactlyOnly if the seed and the history length match
Typical useReference levels, long horizons, anything quoted publiclyA faster average where a finite window is wantedInputs to other indicators, and shorter horizons

The row worth dwelling on is the second. A simple average moving down on an up day is not a fault, and it is the single most common source of confusion about these lines: the average is a statement about a window, and windows have two ends.

Averaging volume rather than price

The same three formulas apply unchanged to a volume series, and this is where an average earns its place on a site about volume: nearly every measure in the indicator library that calls a session heavy or light is comparing it against a volume average, explicitly or otherwise.

The arithmetic transfers; the interpretation does not. Volume carries a strong weekly pattern and a strong intraday one, so a five-day volume average is partly measuring which days of the week it happens to contain, and a short intraday one is measuring the time of day. Use a period long enough to span several complete cycles of whatever pattern your data has (twenty sessions is the usual minimum for daily data), and read the result as a ratio rather than a level, which is what the average volume page sets out.

Checking an implementation in three minutes

Paste your own closes into the tool above and compare against your platform in this order, because the causes are ranked by how often they turn out to be the answer.

First the simple average, which has no free parameters. If that disagrees, the problem is the input series, an off-by-one in the window, or adjusted against unadjusted prices around a split or a dividend. Fix it before looking at anything else, because everything downstream inherits it.

Then the smoothing constant, by computing the exponential average for the same period both ways. If your platform’s figure sits between the two, it is using a third convention and its documentation will say which.

Then the history. Feed both several hundred bars. A disagreement that shrinks as the history lengthens was always a seed difference, and there is nothing to fix, the two series converge because that is what the decay does.

What survives all three is a genuine difference in the input series, and at that point the question stops being about moving averages. This is the whole reason the tool prints its intermediate columns: a number you can reproduce is a number you can argue about productively.

Frequently asked questions

Which of the three should I use?

The one whose behaviour you can predict, which for most purposes is the simple average. It is the only one of the three that treats every bar in its window identically and drops each bar cleanly when it leaves. The exponential average responds faster to recent prices and never forgets an old one entirely; the weighted average is a middle case with a fixed window and a linear taper. None is more accurate than another, because none of them is estimating anything: they are three different summaries of the same prices.

Why does my platform give a different exponential average?

Almost always because of the seed or the smoothing constant. The conventional exponential average uses a multiplier of 2 ÷ (n + 1); Wilder’s smoothing, used inside RSI and ATR, uses 1 ÷ n, which for the same n responds roughly half as fast. And the first value has to come from somewhere, a simple average of the first n bars is the common choice, but some implementations seed with the first close alone. Both differences persist in the series for a long time, so two correct implementations disagree for dozens of bars.

How much history does an exponential average need?

More than its period suggests. Because every past bar keeps a decaying weight for ever, the value at any point is partly a function of where your data began. A rough rule is that the seed’s influence falls below a per cent after about three to four times the period, so a 50-period exponential average fed 60 bars is still substantially describing its own seed. If you are comparing with a platform, give both the same long history before concluding anything.

Does the weighted average have any advantage?

One, and it is real: it responds faster than a simple average of the same length while keeping a finite window, so it forgets old bars completely rather than asymptotically. That makes it easier to reason about than an exponential average and quicker than a simple one. It is less common mostly for historical reasons. The exponential form was cheaper to compute when these methods were done by hand or on early machines, because it needs only the previous value.

What does a crossover actually tell me?

That the shorter average has moved above or below the longer one, which is a statement about the past that is true by construction. Whether it carries information about the future is a separate claim requiring evidence, and the evidence is weak and heavily dependent on the market, the period and the era tested. What a crossover reliably does is impose a rule, and having a rule has value independent of whether the rule predicts anything.

Should I use closes, or an average of high, low and close?

Closes, unless you have a specific reason otherwise, because the close is the price with the most agreement behind it, the point at which the largest number of participants settled. A typical price averaging high, low and close is smoother and reflects where the session traded rather than where it ended, which suits volume-weighted work. What matters is stating which you used: two averages computed from different input series are not comparable, and this is a common hidden cause of a mismatch.

Can I average something other than price?

Yes, and volume is the most useful case. A volume average gives you a baseline against which a session can be called heavy or light, which is what nearly every volume measure on this site depends on. The arithmetic is identical; the interpretation is not, because volume has a strong day-of-week and time-of-day pattern that price does not, so a short volume average is partly measuring the calendar.

What period should I choose?

One that matches the horizon you are looking at, and then stick with it. The widely quoted lengths — 20, 50, 200 — are conventions that became self-fulfilling to a degree, because enough participants watch them that price sometimes reacts around them. That is a genuine reason to know where they are and a poor reason to believe they are special. Choosing a period by testing which one performed best on the data you have is the most reliable way to produce a number that will not repeat.