Simple Moving Average (SMA)

Definition & how to use this technical indicator for quantitative investing

Simple Moving Average (SMA) is a technical indicator that is commonly used in financial analysis and trading. Moving averages are versatile tools that can be used to identify trends, support and resistance levels, and other trading opportunities.

Simple moving averages can be used in various ways, including:

  • Trend Identification: Moving averages can help identify the overall trend of a security by smoothing out fluctuations in the price.
  • Support and Resistance: Moving averages can act as support or resistance levels, as they provide a visual representation of the average price of a security over a given time period.
  • Buy and Sell Signals: Moving averages can be used to generate buy and sell signals by combining them with other technical indicators or chart patterns.
  • Momentum Indicator: Moving averages can be used as a momentum indicator, which measures the rate of change in the price of a security.

How SMA works:

To calculate an SMA, you take the sum of prices over the selected period (typically the closing price) and divide that number by the number of periods. For example, to calculate a 7-day moving average, simply add up the asset's closing prices over the 7 previous trading days and divide the result by 7.

Let’s do a hypothetical example for a 7-day moving average using the Apple stock (ticker $AAPL).

  • Day 1 (Monday, January 1st): $110.00 closing price
  • Day 2 (Tuesday, January 2nd): $106.50 closing price
  • Day 3 (Wednesday, January 3rd): $103.25
  • Day 4 (Thursday, January 4th): $105.75 closing price
  • Day 5 (Friday, January 5th): $104.00 closing price
  • Day 6 (Monday, January 8th): $102.50 closing price
  • Day 7 (Tuesday, January 9th): $101.25 closing price

To calculate the 7-day SMA as of January 9th, add up the previous closing prices from the last 7 trading days ($110.00 + $106.50 + $103.25 + $105.75 + $104.00 + $102.50 + $101.25 = $733.25) and divide the result by 7 ($733.25 / 7 = $104.75). So on January 9th, Apple’s SMA was $104.75.

You can use almost any period of time with simple moving averages; 7-day, 20-day, 50-day, 200-day, or even longer periods like 50-week, and even 50-month. The longer the period, the slower the SMA line will react to recent changes in the stock price. The most common periods are the 50-day and 200-day SMAs.

Technical analysis with SMA

Support & Resistance

Traders commonly use SMA lines as either potential support or resistance for the underlying asset price. If a stock is in a downtrend and bounces back up to a significant SMA line, there may be some price resistance, and vice versa.

Let’s look at an example. Below is a hypothetical graph of ABC Corp’s stock (ticker $ABC). The grey line represents their share price, while the blue line represents the 10-day SMA. As you can see, shares of ABC Corp trended down during this period, and when looking to rally back, it was rejected at its 10-day SMA on four separate occasions!

Illustration of support & resistance of the simple moving average (SMA) indicator


Traders often use SMA crossovers, such as the death cross and golden cross, to identify potential trading signals. To trade using crossovers, you need two SMAs with offsetting periods such as a 5-day SMA and a 20-day SMA. As the name sounds, you enter or exit a position when the two SMAs crossover.

Golden Cross = shorter-term SMA crosses above the longer-term SMA. This is typically a signal to buy, as it could be the early stages of a reversal to an uptrend.

Death Cross = shorter-term SMA crosses below the longer-term SMA. This is typically a signal to sell, as it could be the early stages of a reversal to a downtrend.

Let’s look at an example…Below is another hypothetical graph of ABC Corp . The blue line is the 5-day SMA (shorter-term) and the orange line is the 20-day SMA (longer-term). The green circle plotted on the graph display where a golden cross has occurred, and represents an opportunity to enter a long position. The red circle, on the other hand, displays where a death cross has occurred, and represents a potential spot to exit a long position.

Illustration of crossover of the simple moving average (SMA) indicator


Is the SMA perfect? No. It has plenty of limitations. For starters, it relies on historical data which may not reflect current market conditions accurately and nothing about the calculation is predictive in nature. At times, the market seems to respect SMA support and resistance lines, and at other times, it shows these indicators no consideration. Another limitation is that SMAs can be slow to react to recent price changes due to the calculation giving equal weights to all data points in the time frame. That is where the Exponential Moving Average (EMA) can add value.


Overall, SMA is a valuable tool for traders to understand the price trends of assets and make informed investment decisions based on historical price data. Please check out the Alpha Vantage Technical Indicator APIs to access 50+ technical indicators programmatically with ease.