Skip to content
TraderCalcs.io

Moving Average Calculator

Calculate simple, exponential and weighted moving averages from a price series you enter, side by side.

A moving average is the mean of the last n prices, recomputed as each new price arrives. This moving average calculator produces three of them from one series you type in — the simple moving average, the exponential moving average and the weighted moving average — over the same window and side by side, because the only genuinely useful thing to say about any one of them is how it differs from the other two. Running a separate SMA calculator, EMA calculator and weighted moving average calculator over the same prices would hand you the same three numbers with the comparison left out, and the comparison is the part worth having.

Formula: EMA = price x (2 / (n + 1)) + previous EMA x (1 - 2 / (n + 1))

Your figures

How many bars each average covers. The series below holds 24 prices, so any period from 2 to 24 works as it stands; longer periods need more rows.

Where the exponential average starts. This is the usual reason two platforms report different EMAs for the same prices.

Price series

Oldest first, newest last — the order matters, because the weighted and exponential averages both weight by position. Any price you like: a close, a mid, a settlement. Blank rows are ignored.

Bar 1
Bar 2
Bar 3
Bar 4
Bar 5
Bar 6
Bar 7
Bar 8
Bar 9
Bar 10
Bar 11
Bar 12
Bar 13
Bar 14
Bar 15
Bar 16
Bar 17
Bar 18
Bar 19
Bar 20
Bar 21
Bar 22
Bar 23
Bar 24

Results

Simple moving average

102.6750

the mean of the last 20 of 24 prices

Exponential moving averageSmoothing multiplier 0.0952, which is 2 ÷ (20 + 1). Simple average less exponential average: -0.0766.
102.7516
Weighted moving averageWeights rise in a straight line from 1 on the oldest price in the window to 20 on the newest.
103.3505
Latest priceThe final price in the series. All three averages are measured to it.
104.4000
Latest price less the simple average+1.680% of the simple average.
+1.7250
Latest price less the exponential average+1.604% of the exponential average.
+1.6484
Latest price less the weighted average+1.015% of the weighted average.
+1.0495
EMA seeded fromThe recursion starts at bar 20 holding the simple average of the window that ends there.
Simple average of the first 20
Prices usedEvery row entered held a price.
24
Bar 20Price 102.9000 · EMA 101.8900 · WMA 102.4767
101.8900
Bar 21Price 103.8000 · EMA 102.0719 · WMA 102.6586
102.0800
Bar 22Price 104.6000 · EMA 102.3127 · WMA 102.8986
102.2800
Bar 23Price 105.1000 · EMA 102.5781 · WMA 103.1671
102.4750
Bar 24Price 104.4000 · EMA 102.7516 · WMA 103.3505
102.6750

What this means

Over the last 20 of the 24 prices entered, the simple average is 102.6750, the exponential average is 102.7516 and the weighted average is 103.3505. All three describe that same window and differ only in how weight is distributed across it: the simple one spreads it evenly, the weighted one ramps it from 1 on the oldest price to 20 on the newest, and the exponential one applies 0.0952 to each arriving price and lets the remainder decay. The final price of 104.4000 is +1.7250 from the simple average, a gap of +1.680%. That gap is a subtraction between two numbers already computed from prices that have printed.

  • The three averages cover the same window and differ only in how they spread weight across it: evenly, in a straight line, or decaying geometrically. Which one sits highest at the latest bar describes how the recent prices were distributed and nothing else.
  • An exponential average never fully discards a price. A 20-period EMA is a 20 only in the sense that its centre of mass matches a 20-period simple average — every earlier price is still in the figure, with a weight that has decayed rather than reached zero.
  • Two platforms can report different EMAs from identical prices because they seed the recursion differently. Both seedings are offered above and the one used is named in the result.
  • Every price here is one you entered. Nothing is fetched and no market, bar size or session is assumed, so the same calculation serves a five-minute chart, a daily chart and a column of weekly closes without knowing which it has been given.
  • These are descriptions of arithmetic performed on prices that have already printed. Where the latest price sits relative to a line says nothing about where the next one will be.

Simple moving average: 102.6750

The link reopens this calculator with the same numbers. Nothing you enter is sent to a server.

About the Moving Average calculation

All three cover identical prices and differ solely in how they spread weight across them. The simple average spreads it evenly, so a price counts as much on the bar it leaves the window as on the bar it entered. The weighted average ramps weight in a straight line, from 1 on the oldest price in the window to n on the newest. The exponential average decays it geometrically and never discards anything, which is why a twenty-period EMA still carries a trace of a price from two hundred bars ago.

The exponential average is also where two platforms most often disagree about the same prices, and the reason is almost never a fault in either of them. An EMA is recursive, so it has to be started somewhere, and where it is started changes every value that follows it for the rest of the series. Both of the common starting conventions are offered here as a choice rather than picked silently, and the result names the one it used.

Which of the three lines sits highest at the latest bar describes how the recent prices happened to be distributed inside the window, and nothing beyond that. The gap between the latest price and any of these lines is a subtraction between two figures computed from prices that have already printed, not a statement about the next one.

Moving Average formula

n prices, p_1 … p_i, oldest first

SMA = (p_(i−n+1) + … + p_i) ÷ n

k   = 2 ÷ (n + 1)
EMA = previous EMA + k × (p_i − previous EMA)
    = k × p_i + (1 − k) × previous EMA        (the same expression)

  seed, from which the recursion starts:
    simple average — EMA at bar n = the SMA of p_1 … p_n
    first price    — EMA at bar 1 = p_1, then run forward

WMA = (p_(i−n+1) × 1 + … + p_i × n) ÷ (n(n + 1) ÷ 2)

gap to a line    = p_i − that average
gap as a percent = gap ÷ that average × 100
n
The period: how many bars each average covers. You choose it, and any value from 2 up to the number of rows entered is accepted.
p_i
The i-th price in the series, counting from the oldest. Order matters, because the weighted and exponential averages both weight by position.
k
The exponential smoothing multiplier, 2 ÷ (n + 1). It is the share of each arriving price taken into the average; the remainder, 1 − k, is what the previous value keeps.
n(n + 1) ÷ 2
The sum of the weights 1, 2, … n that the weighted average divides by. For a four-bar window it is 10; for twenty bars it is 210.
seed
The value the exponential recursion begins from. It is a convention rather than a derived quantity, and different platforms use different ones.

The three averages are the same operation carried out with three different weight vectors over the same window, which is why comparing them is worth more than reading any one alone. A simple average uses a flat vector, a weighted average one rising in a straight line, an exponential average one falling away geometrically into the past. When the weighted line sits above the simple one, the newer prices in the window are higher than the older ones, and that is the whole of what the ordering tells you.

The exponential multiplier k = 2 ÷ (n + 1) is a convention rather than a result. It was chosen so that an n-period exponential average has roughly the same centre of mass as an n-period simple average, which makes the two loosely comparable at the same setting. Nothing derives it, and a different multiplier would give a perfectly valid exponential average of a different shape. For a four-bar window k is 0.4000; for twenty bars it is 0.0952.

That also means a twenty-period EMA is a twenty only in a nominal sense. Unlike the other two it has no window edge: every price ever fed into it is still in the number, carrying a weight that has decayed towards zero without arriving there. A price from n bars ago retains about 14% of its original weight. The simple and weighted averages, by contrast, drop a price the instant it falls out of the window, which is why a large value leaving the window jolts them and cannot move the exponential line at all.

Because the recursion has no natural beginning, the seed is a free choice, and it is the usual reason two platforms report different EMAs from the same prices. Seeding with the simple average of the first n prices is the textbook construction and the default here; seeding with the first price alone and running forward from bar one is what several charting packages do. On a long series the two converge, and on the twenty or thirty rows someone actually types into a form they do not. In the worked example below the same six prices give 104.88 under one seed and 105.0701 under the other.

Moving Average: a worked example

Six prices in the order they printed — 100, 102, 101, 105, 104 and 108 — averaged over a four-bar window, with the exponential average seeded from the simple average of the first four.

  1. Simple average of the last four(101 + 105 + 104 + 108) ÷ 4 = 418 ÷ 4 = 104.50
  2. Weighted average of the last four(101 × 1 + 105 × 2 + 104 × 3 + 108 × 4) ÷ 10 = 1,055 ÷ 10 = 105.50
  3. EMA multiplier2 ÷ (4 + 1) = 0.4000
  4. EMA seed at bar 4(100 + 102 + 101 + 105) ÷ 4 = 102.00
  5. EMA at bar 5102.00 + 0.4 × (104 − 102.00) = 102.80
  6. EMA at bar 6102.80 + 0.4 × (108 − 102.80) = 104.88
  7. Latest price against the simple average108 − 104.50 = +3.50, which is +3.349% of it

Simple 104.50, exponential 104.88, weighted 105.50, from identical prices. The ordering follows from the last two bars being the strongest in the window: the flat weighting counts the weak 101 as heavily as the 108, the linear weighting counts the 108 four times as heavily, and the exponential weighting sits between them. Change one setting and the picture moves — seeded from the first price instead, the exponential average reads 105.0701 rather than 104.88, on exactly the same six numbers.

How to use the Moving Average calculator

  1. Enter your prices oldest first and newest last. The order is not cosmetic: the weighted and exponential averages both weight by position, so a series entered backwards produces a different and meaningless answer. Closes are conventional, but a mid or a settlement works identically — the arithmetic does not know what it has been given.
  2. Set the period to the number of bars each average should cover. The series opens with 24 prices behind it, so anything from 2 to 24 works as it stands, and longer periods need more rows.
  3. Choose the EMA seed. Leave it on the simple average for the textbook construction, or switch to the first price if you are reconciling against a platform that starts its recursion there.
  4. Read the three averages together rather than one at a time, along with the simple-less-exponential row and the three gap rows beneath them. Each gap is given in price units and as a percentage of the line it was measured from, so gaps on an index and on a share can be compared.
  5. Scroll to the per-bar rows at the bottom to watch the lines evolve over the last eight bars. Seeing all three against the price is what makes the difference in responsiveness visible rather than asserted.

Limitations of the Moving Average calculator

Every calculation makes assumptions. These are the ones that matter here.

  • Every moving average lags by construction. It is a mean of prices that have already printed, so it must sit behind a series moving in one direction, and the lag grows with the period.
  • Only the prices entered are averaged, and nothing here knows what a bar is. A spike between two of your rows is invisible, so daily and hourly rows over the same stretch give different lines, and a series of unevenly spaced bars is not the average it appears to be.
  • The exponential average depends on its seed, and on a short series that dependence is material. Two platforms agreeing on the prices can still disagree on the EMA by a visible amount for dozens of bars.
  • A crossing of two averages is an arithmetic event about past prices, not information about future ones. This calculator reports the levels and the gaps between them and draws no conclusion from either.
  • All three averages weight by position in the series and none of them weights by volume. Where the volume traded should matter, the volume-weighted average price calculator is the measure that uses it.

Frequently asked questions about Moving Average

What is the practical difference between an SMA and an EMA?

The simple average treats every price in the window identically and forgets each one completely when it drops out of the window. The exponential average weights the newest price most heavily and forgets nothing, letting older prices fade rather than fall away. The practical consequence is that a large value leaving the window jolts the simple average and does nothing at all to the exponential one.

Why does my charting platform show a different EMA for the same prices?

Almost always because it seeds the recursion differently. An EMA has no first value of its own, so one has to be supplied, and starting from the simple average of the first n prices and starting from the first price alone give different numbers at every subsequent bar. The gap narrows as the series lengthens but never quite closes. Both seedings are offered above, and the result panel names the one it used so the two can be reconciled.

What period should I use for a moving average?

No period is correct in the abstract, which is why nothing here is preset beyond a conventional default of 20 that you can change. A shorter period tracks the price more closely and turns more often; a longer one is smoother and slower. Typing a series in by hand exists precisely so the same prices can be looked at through a 9, a 20 and a 50 without any of them being treated as the right answer.

Does a moving average say anything about where the price is going next?

No. It is a mean of prices that have already printed, and a mean cannot contain information the prices did not. Where the latest price sits relative to any of these three lines is the result of a subtraction between two computed figures. This calculator reports levels and distances and makes no claim about whether any of them will be revisited.

Why does the exponential moving average formula use 2 ÷ (n + 1) rather than 1 ÷ n?

Convention, chosen so that an n-period exponential average has approximately the same centre of mass as an n-period simple average and the two can be set to the same number and loosely compared. Nothing derives it from first principles. Some older texts use other multipliers, and an exponential average built on 1 ÷ n is a perfectly valid smoother — it simply corresponds to a different effective period.

Last reviewed . See our methodology and editorial policy.

More technical calculators