Moving Average

A moving average is a technical indicator that smooths out price data by creating a constantly updated average price. Traders use it to identify the direction and strength of a trend, filtering out the day-to-day noise of market fluctuations.

The simple moving average — formula and intuition

The Simple Moving Average (SMA) is the most basic form of the indicator. It is calculated by summing the closing prices of the last n periods and then dividing that sum by n. It is a simple, unweighted arithmetic mean.

The formula for the SMA at time t over an n-period lookback window is:

Here, is the price at time . The calculation is a “moving” or “rolling” window across the price series. As a new price bar forms, the oldest price bar in the window is dropped and the new one is added.

A diagram showing a 20-bar rolling window over a price chart, illustrating how a Simple Moving Average is calculated from the mean of those 20 closes.

For a concrete example, consider the last five closing prices for a NIFTY futures contract: Rs. 21,540, Rs. 21,605, Rs. 21,520, Rs. 21,610, and Rs. 21,655. The 5-period SMA is calculated as:

Intuition. The SMA represents the “centre of mass” of the price over the last n bars. Every data point in the window is given equal weight, just like every particle in a uniform physical object contributes equally to its centre of mass.

How traders use the moving average

Traders use moving averages primarily for two purposes: identifying trend direction and locating dynamic support or resistance levels.

Trend Direction

The simplest use is to gauge the trend. If the price is consistently trading above a moving average and the MA itself is sloping upwards, the trend is considered bullish. Conversely, if the price is below a downward-sloping MA, the trend is bearish. The steepness of the MA’s slope can indicate the momentum of the trend.

Support and Resistance

In a trending market, a moving average often acts as a dynamic level of support (in an uptrend) or resistance (in a downtrend). Price will pull back to the moving average during minor corrections before resuming the trend. This provides a high-probability area to enter a trade in the direction of the trend.

A price chart showing an uptrend where the 20-period moving average acts as a dynamic support level, with three clear instances of the price pulling back to the MA and bouncing.

Choosing the MA period involves a trade-off between sensitivity and reliability.

Period (n) Typical Use Case Speed Reliability
10, 20 Short-term, intraday trading (e.g., 15-min chart) Fast, responsive Less reliable, prone to “whipsaws”
50 Medium-term trend, swing trading (e.g., hourly/daily chart) Moderate Balanced
200 Long-term trend, investment (e.g., daily/weekly chart) Slow, lagging More reliable, confirms major trends

Types of moving averages

While the SMA is common, several other types of moving averages exist. They differ in how they weight the price data. The goal of these variations is typically to reduce the lag inherent in the SMA.

  • Simple Moving Average (SMA): As discussed, gives equal weight to all prices.
  • Exponential Moving Average (EMA): Gives more weight to recent prices, making it more responsive to new information.
  • Double Exponential Moving Average (DEMA): An even faster-reacting average that further reduces lag by taking a smoothed average of an EMA.
  • Weighted Moving Average (WMA): Similar to EMA, it assigns more weight to recent prices, but does so in a linear fashion.

The EMA is calculated recursively. The formula uses a smoothing factor , which is derived from the period n.

The DEMA is a refinement of the EMA, not of the price itself. It is defined as:

The difference in weighting, or the “kernel,” is what distinguishes these averages. The SMA has a flat, uniform kernel, while the EMA and DEMA have kernels that decay exponentially, focusing more weight on the most recent bars.

A bar chart comparing the kernel weights of SMA, EMA, and DEMA over a 40-bar lookback period, showing EMA and DEMA weights decaying exponentially while SMA is uniform.

On a chart, this translates to the EMA and DEMA hugging the price more closely than the SMA.

A NIFTY price chart with a 20-period SMA, EMA, and DEMA overlaid, demonstrating that the DEMA follows the price most closely and the SMA follows most loosely.

The practical benefit is reduced lag. When price makes a sudden move, the DEMA will react the fastest, followed by the EMA, and then the SMA. DEMA’s construction mathematically attempts to cancel out the inherent lag of a standard exponential moving average.

A chart showing a sudden price step from 100 to 120, with the DEMA responding fastest to the new price, followed by the EMA, and then the lagging SMA.

Moving-average crossovers

A popular trading strategy involves plotting two moving averages with different periods—a “fast” MA and a “slow” MA (e.g., 10-period and 50-period, or 50-period and 200-period). A trading signal is generated when the two MAs cross.

  • A bullish crossover (or “golden cross”) occurs when the fast MA crosses above the slow MA. This suggests upward momentum is building.
  • A bearish crossover (or “death cross”) occurs when the fast MA crosses below the slow MA. This suggests downward momentum is building.

A NIFTY chart showing a 10-period SMA crossing over a 50-period SMA. Bullish crossovers are marked with green dots and bearish crossovers with red dots, indicating changes in trend.

Pitfall. Crossover signals are, by definition, lagging indicators. The market must move significantly before the averages cross. In sideways or choppy markets, this lag leads to “whipsaws”—a series of losing trades where a signal is generated just as the move is reversing. Mathematically, for a linear trend, an n-period SMA lags the price by bars.

Summary

This lesson covered the foundational concepts of the moving average indicator.

  • A moving average smooths price data to reveal the underlying trend.
  • Traders use it to determine trend direction and identify dynamic support/resistance levels.
  • The choice of period (e.g., 20, 50, 200) is a trade-off between responsiveness and reliability.
  • Different types exist (SMA, EMA, DEMA), which primarily vary by how they weight recent price data to reduce lag.
  • The crossover of a fast and slow moving average is a common method for generating trend-following trade signals, though it is a lagging technique.

In the next lesson, we will see how the moving average forms the core component of Bollinger Bands, a volatility envelope.

Post a comment

Leave a Comment

Your email address will not be published. Required fields are marked *

×Close