TL;DR
A moving average smooths price data by calculating the average closing price over a specified number of periods, helping traders identify trend direction and dynamic support/resistance levels.
Table of Contents
A moving average (MA) is one of the most widely used technical indicators in trading. It calculates the average price of an asset over a specified number of periods, creating a smooth line on the chart that filters out short-term price noise and reveals the underlying trend direction. The line is called 'moving' because it recalculates with each new period, dropping the oldest data point and adding the newest one. Moving averages serve three primary functions: trend identification (price above the MA suggests an uptrend, below suggests a downtrend), dynamic support and resistance (price often bounces off key moving averages), and signal generation (crossovers between different MAs can trigger buy and sell signals). They are used by everyone from individual day traders to hedge fund algorithms and are available on every charting platform.
The two most common types of moving averages are the Simple Moving Average (SMA) and the Exponential Moving Average (EMA). The SMA gives equal weight to every price in the calculation period: it sums all closing prices and divides by the number of periods. The EMA applies a multiplier that gives more weight to recent prices, making it more responsive to current price action. Because the EMA reacts faster to price changes, it is preferred by short-term and day traders who need timely signals. The SMA, being smoother, is preferred by swing traders and position traders who want to avoid whipsaws. Neither is inherently better; the choice depends on your trading style and how quickly you want the average to respond to price changes.
SMA = (P1 + P2 + ... + Pn) / nP — Closing price of each period
n — Number of periods (lookback length)
| Type | Calculation | Responsiveness | Best For |
|---|---|---|---|
| SMA | Equal weight to all periods | Slower, smoother | Swing and position trading |
| EMA | More weight to recent prices | Faster, more reactive | Day trading and scalping |
| WMA | Linear weight (recent = heavier) | Between SMA and EMA | Specialized analysis |
Certain moving average periods have become standard in the trading community, each serving a different purpose. The 9 and 21-period EMAs are popular among day traders and scalpers for capturing short-term momentum. The 50-period SMA or EMA is widely used to define intermediate trend direction and acts as dynamic support or resistance in trending markets. The 200-period SMA is the most watched moving average globally and is considered the dividing line between bull and bear markets by institutions and fund managers. When the 50-day SMA crosses above the 200-day SMA, it is called a Golden Cross, which is a bullish signal. When it crosses below, it is called a Death Cross, a bearish signal. While these names sound dramatic, these crossovers are lagging signals and should be confirmed with other analysis.
| Period | Common Use | Significance |
|---|---|---|
| 9 EMA | Very short-term momentum | Scalping and intraday momentum |
| 21 EMA | Short-term trend | Day trading trend filter |
| 50 SMA/EMA | Intermediate trend | Dynamic S/R, widely followed by institutions |
| 100 SMA | Medium-term trend | Secondary trend confirmation |
| 200 SMA | Long-term trend | Bull/bear market divider, strongest dynamic S/R |
Pro Tip
The 200-day SMA is arguably the single most important technical level in any market. Institutional traders, hedge funds, and algorithmic systems all monitor it. When price approaches the 200 SMA after an extended trend, expect a significant reaction.
Moving average crossovers are among the most popular trading signals. A bullish crossover occurs when a shorter-period MA crosses above a longer-period MA, indicating that recent price momentum is turning upward. A bearish crossover occurs when the shorter MA crosses below the longer MA. Common crossover pairs include the 9/21 EMA crossover for short-term trading, the 20/50 EMA crossover for intermediate signals, and the 50/200 SMA crossover (Golden Cross/Death Cross) for long-term trend changes. While crossovers are simple and objective, they are inherently lagging indicators because they are based on past prices. This means they work well in trending markets but produce many false signals in choppy, range-bound conditions. To filter false signals, many traders add a momentum confirmation (such as RSI) or volume requirement before acting on a crossover.
While the SMA calculation is straightforward, the EMA calculation involves a weighting multiplier that gives more importance to recent prices. Understanding this math helps you appreciate why the EMA reacts faster. The EMA multiplier (also called the smoothing factor) is calculated as: Multiplier = 2 / (Period + 1). For a 12-period EMA, the multiplier is 2 / 13 = 0.1538, meaning the most recent price receives about 15.38% of the total weight. For a 26-period EMA, the multiplier is 2 / 27 = 0.0741, so the most recent price gets only 7.41% weight. Once you have the multiplier, each new EMA value is calculated as: EMA = (Current Price - Previous EMA) x Multiplier + Previous EMA. For example, if yesterday's 12-period EMA was 5,000 and today's closing price is 5,020, today's EMA = (5,020 - 5,000) x 0.1538 + 5,000 = 3.08 + 5,000 = 5,003.08. Notice how the EMA moved only 3.08 points toward the new price, not the full 20 points. This smoothing prevents overreaction to single-bar moves while still being responsive to genuine trend changes. The initial EMA value for the first period is typically set equal to the SMA of the first n periods, then the exponential smoothing begins from there.
EMA = (Price - Previous EMA) x [2 / (Period + 1)] + Previous EMAPrice — Current period closing price
Previous EMA — EMA value from the prior period
Period — Lookback length (e.g., 12, 26, 50)
The Golden Cross (50 SMA crossing above 200 SMA) and Death Cross (50 SMA crossing below 200 SMA) are among the most widely discussed technical signals in financial media. Their track record is instructive. In the S&P 500, the Golden Cross that occurred in June 2020 preceded a rally of over 40% over the following 12 months. The Death Cross in March 2020 occurred near the COVID crash bottom, demonstrating a key limitation: these signals are lagging and can trigger after a significant move has already occurred. Historically, since 1950, the S&P 500 has averaged a 6.3% gain in the 6 months following a Golden Cross and a -1.2% return in the 6 months following a Death Cross. These are meaningful differences but not reliable enough to trade in isolation. The lag time between the actual trend change and the crossover signal averages 30-50 trading days. For this reason, many professional traders use the Golden Cross and Death Cross as trend confirmation filters rather than entry signals. For example, they only take long setups in individual stocks or futures when the broader market (S&P 500) is in a Golden Cross configuration. This macro filter alone can significantly improve win rates by keeping you on the right side of the dominant trend. The most powerful application is using the Death Cross as a regime filter: when the 50 SMA is below the 200 SMA, reduce position sizes by 50% or move to cash, as this regime historically has higher volatility and larger drawdowns.
| Signal | S&P 500 Avg 6-Month Return | Avg Lag Time | Best Use |
|---|---|---|---|
| Golden Cross | +6.3% | 30-50 trading days | Trend confirmation, long-only filter |
| Death Cross | -1.2% | 30-50 trading days | Risk reduction, position size cut |
In trending markets, moving averages frequently act as dynamic support (in uptrends) or dynamic resistance (in downtrends). During a strong uptrend, price often pulls back to the 21 EMA or 50 SMA and bounces, providing low-risk entry opportunities for trend-following traders. The strength of the moving average as support depends on both the period and how well-established the trend is. In a powerful uptrend, the 9 or 21 EMA may act as support. In a more moderate uptrend, the 50 SMA is the typical level. In a weakening uptrend, price may need to pull back all the way to the 200 SMA before finding support. The angle of the moving average also matters: a steeply rising MA provides stronger support than a flat or barely rising one because it reflects strong underlying momentum. When price breaks below a key moving average that has provided support multiple times, it often signals a trend change.
Pro Tip
In a healthy uptrend, look for buying opportunities when price touches or slightly dips below the 21 EMA and then produces a bullish candlestick pattern. Place your stop loss below the 50 EMA for added protection.
NinjaTrader 8 includes SMA, EMA, WMA, and several other moving average types as built-in indicators. To add a moving average to your chart, right-click the chart, select Indicators, and choose SMA or EMA from the list. You can overlay multiple moving averages with different periods and colors to create a complete visual framework. A recommended NinjaTrader setup is to add a 21 EMA (blue), 50 SMA (orange), and 200 SMA (red) to your chart. This gives you short-term momentum, intermediate trend, and long-term trend at a glance. In NinjaScript, accessing moving averages is straightforward: double ema21 = EMA(21)[0] gives you the current 21-period EMA value, and double sma200 = SMA(200)[0] gives the current 200 SMA. You can build crossover strategies with simple conditions: if (CrossAbove(EMA(12), EMA(26), 1)) EnterLong(). NinjaTrader also supports adaptive moving averages like KAMA (Kaufman Adaptive Moving Average) and TEMA (Triple Exponential Moving Average), which adjust their smoothing based on market conditions. For NinjaTrader users running automated strategies, one practical tip is to use a 200 SMA filter on the daily chart as a trade direction filter. Only allow long entries when the daily close is above the 200 SMA, and only allow short entries when below. This single filter can eliminate a significant portion of losing trades in trend-following systems by keeping you aligned with the dominant market direction.
Mistake
Using moving average crossovers in range-bound markets
Correction
Moving average crossovers work best in trending markets. In choppy conditions, they produce frequent false signals. First identify the market environment, then decide whether to use crossover signals.
Mistake
Changing moving average settings constantly to fit recent price action
Correction
Choose standard periods (9, 21, 50, 200) and stick with them. These work because many traders watch them, creating a self-fulfilling effect. Custom periods may optimize past results but have no edge going forward.