Moving averages: SMA and EMA explained

By Oalgo · Last reviewed

A moving average is the average price over the last few candles, recalculated at each new candle. It smooths out small moves so the direction is easier to see.

Chart: example prices with a 20-period SMA and a 20-period EMA. The EMA follows turns sooner than the SMA.PriceSMA 20EMA 20EMA turns first
Example prices, made up for this page.

What is a simple moving average (SMA)?

#

The SMA adds the closing prices of the last N candles and divides by N. Every candle counts the same. A 20-period SMA is the average of the last 20 closes.

What is an exponential moving average (EMA)?

#

The EMA gives more weight to recent candles, so it turns sooner when price turns. The weight is 2 ÷ (N + 1): for a 20-period EMA, each new close counts for about 9.5% of the new value.

SMA or EMA?

#
SMAEMA
Reacts to new pricesSlowerFaster
Small movesSmoothed moreSmoothed less
Good forThe broad directionTurns that happen sooner

How do people use moving averages in rules?

#
  • Price above or below the average, as a filter: for example, only enter when the close is above the 50-period SMA.
  • Two averages crossing: a short EMA crossing above a longer one.
  • The slope of the average, to see whether the direction is up or down.
  • A trend filter next to another indicator, such as RSI.

None of these works every time. Test any rule on past prices first with a backtest, then forward test it.

In Oalgo you can tell Oalgo AI your moving average rule in your own words, check the rule it builds, and test it. After testing, if you choose, you Go Live with your own Live Strategy on your own Venue Account at a Supported Venue.

Read next