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.
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?
#| SMA | EMA | |
|---|---|---|
| Reacts to new prices | Slower | Faster |
| Small moves | Smoothed more | Smoothed less |
| Good for | The broad direction | Turns 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
- What is RSI? The RSI indicator explainedThe RSI indicator compares recent up moves with down moves on a scale from 0 to 100. Learn how it is calculated, how to read it, and how to test RSI rules.
- What is backtesting?Backtesting runs your rules on past prices to see how they would have behaved. Learn what it shows, what it cannot show, and how to read the report.