Why usFeaturesTemplatesBlogGlossary

Simple Moving Average (SMA)

The unweighted mean of a security's price over a fixed number of past bars, used to smooth short-term noise and describe the direction of a trend.

A simple moving average is the arithmetic mean of the last N bars. Take the most recent 50 closes of RELIANCE, add them, divide by 50. Repeat tomorrow with the newest close in and the oldest one out. The line that results is @SMA(close, 50).

How it is computed

SMA(N) = (P_1 + P_2 + ... + P_N) / N

Every bar in the window carries the same weight, whether it printed yesterday or fifty sessions ago. The output is in the same units as the input, so an SMA of close is a rupee price and compares to price directly:

close > @SMA(close, 200)

Two lengths compared against each other describe whether the short-run average sits above the long-run one:

@SMA(close, 50) > @SMA(close, 200)

Typical windows

ExpressionRoughlyCommonly read as
@SMA(close, 20)one trading month on NSEshort-term drift
@SMA(close, 50)one quarterintermediate trend
@SMA(close, 200)ten monthslong-run regime filter

These lengths come from chart-reading practice that predates computers, when a trader drew the line by hand and round numbers were easier to maintain. The 200-day average is a convention, not a value anyone derived from NSE data. Treat the table as a starting point, not a recommendation.

How to read the output

An SMA describes where price has been. It says nothing about where price is going. Price above its 200-day average tells you the stock is above its own ten-month mean, which is a fact about the past, not a forecast. Any predictive content has to be established by a backtest with costs, not assumed from the shape of the line.

Risks and caveats

An N-bar average lags by roughly N/2 bars by construction. That lag is the price you pay for smoothing, and no parameter choice removes it.

In a range-bound market the lag turns into whipsaw. A stock oscillating in a band crosses its own average repeatedly, and each crossing generates an entry or an exit that costs brokerage, STT and slippage with no directional move to pay for it. This is structural, not a tuning failure.

Sweeping the window from 5 to 250 and keeping whichever length produced the best historical CAGR is how people overfit. You will always find a winner in a sweep of 245 candidates. Test the survivor on a period you did not search over before trusting it.

One data caveat: a moving average computed on unadjusted prices breaks across splits and bonus issues, because the level shifts without any economic change.

Back to Glossary