Skip to main content

Moving Averages Explained

TL;DR

A moving average smooths price into a line that rises and falls with the trend. The three most common flavors are the Simple (SMA — equal weight), Exponential (EMA — more weight to recent bars), and Weighted (WMA — linear weighting). For futures traders, the 200 EMA is the single most-watched level on the chart, and the 9/21 EMA cross is the workhorse of intraday trend trading.

One price series with a twenty period simple moving average and a twenty period exponential moving average drawn over it. Through the quiet stretch the two lines sit almost on top of each other. When price drops sharply the exponential average turns first because it weights recent bars more heavily, while the simple average lags behind. Faster response also means more false turns in chop, which is the trade being made.

Identical in quiet price. The difference only shows up when direction changes.

The four flavors you need to know​

SMA (Simple Moving Average). Add up the last N closes, divide by N. Every bar counts equally. Smooth and slow.

EMA (Exponential Moving Average). A weighted average where recent bars count more than older ones. Reacts to price changes faster than SMA.

WMA (Weighted Moving Average). Linear weighting — bar N gets N weight, bar N-1 gets N-1 weight, etc. Reacts a bit faster than EMA but is less commonly used.

HMA (Hull Moving Average). A fancier construction designed to cut lag. Smooths as well as SMA but responds as fast as EMA. Popular among intraday traders.

When to use which​

SituationBest choiceWhy
Long-term trend filter200 EMAEvery institution watches it
Intraday trend9 EMA / 21 EMAFast-reacting, widely used
Swing trading baseline50 SMASlow, stable, common reference
Smooth trend with less lagHMAModern pick if you like aggressive smoothing

The boring answer for 90% of traders: use the EMA. It reacts fast enough for intraday work and is universally understood.

The 200 EMA — why it matters​

The 200-period EMA on a daily chart is the most-watched technical level in global markets. Funds use it as a regime filter. Algos pin to it. Price often reacts to it even when nothing else on the chart would suggest it should.

Two practical uses for a day trader:

  1. Trend filter. If daily close is above the 200 EMA, only take longs on lower timeframes. Below, only shorts. This one rule eliminates most counter-trend losses.
  2. Reaction level. When price tags the 200 EMA after trending away from it, expect a reaction — a bounce, a stall, or a break that accelerates.

Moving average crossover​

The classic signal: a fast MA crosses above a slow MA = buy, below = sell.

The 9/21 EMA cross is the most common intraday version. The 50/200 cross ("golden cross" / "death cross") is the headline-friendly version.

Reality check: crossover signals lag. By the time the 9 crosses the 21, the move is often 40% done. Use crossovers as trend confirmation, not entry triggers. Pair with a pullback entry rule or a structure break.

Moving averages in Pine Script (v6)​

//@version=6
indicator("EMA Crossover Alerts", overlay=true)

fastLen = input.int(9, "Fast EMA")
slowLen = input.int(21, "Slow EMA")

fastEma = ta.ema(close, fastLen)
slowEma = ta.ema(close, slowLen)

plot(fastEma, color=color.yellow, linewidth=2, title="Fast EMA")
plot(slowEma, color=color.blue, linewidth=2, title="Slow EMA")

bullCross = ta.crossover(fastEma, slowEma)
bearCross = ta.crossunder(fastEma, slowEma)

plotshape(bullCross, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(bearCross, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)

if bullCross
alert("9/21 EMA bullish cross on " + syminfo.ticker, alert.freq_once_per_bar_close)
if bearCross
alert("9/21 EMA bearish cross on " + syminfo.ticker, alert.freq_once_per_bar_close)

Common mistakes​

  • Chasing magic numbers. 7/14, 8/17, 13/34 — they all work roughly the same. Pick a pair, stick with it.
  • Using SMA for fast signals. SMA lags too much for intraday crossovers. EMA or WMA is the right tool.
  • Ignoring timeframe. A 9 EMA on a 1-minute chart and a 9 EMA on a daily chart are not the same indicator. They represent wildly different amounts of time.
  • Trading every crossover. In a chopping market, 9/21 will cross five times before anything happens. Use an ADX > 20 filter or skip crossovers inside compressed ranges.

How to automate moving average crossovers with CrossTrade​

Convert the indicator above into a strategy(), build the CrossTrade payload inside Pine Script, and pass it to strategy.entry() via alert_message=:

//@version=6
strategy("9/21 EMA Cross — CrossTrade", overlay=true)

fastEma = ta.ema(close, 9)
slowEma = ta.ema(close, 21)
bullCross = ta.crossover(fastEma, slowEma)
bearCross = ta.crossunder(fastEma, slowEma)

if bullCross
msg = "key=YOUR-SECRET-KEY;"
msg := msg + "command=PLACE;"
msg := msg + "account=Sim101;"
msg := msg + "instrument={{ticker}};"
msg := msg + "action=BUY;"
msg := msg + "qty=1;"
msg := msg + "order_type=MARKET;"
msg := msg + "tif=DAY;"
msg := msg + "sync_strategy=true;"
strategy.entry("EMA Long", strategy.long, alert_message=msg)

if bearCross
msg = "key=YOUR-SECRET-KEY;"
msg := msg + "command=PLACE;"
msg := msg + "account=Sim101;"
msg := msg + "instrument={{ticker}};"
msg := msg + "action=SELL;"
msg := msg + "qty=1;"
msg := msg + "order_type=MARKET;"
msg := msg + "tif=DAY;"
msg := msg + "sync_strategy=true;"
strategy.entry("EMA Short", strategy.short, alert_message=msg)

In the TradingView alert dialog: Condition = Order fills only; Message = {{strategy.order.alert_message}}.

The sync_strategy=true flag keeps your NinjaTrader position in lockstep with TradingView's strategy state — if the strategy is flat in TradingView, NT8 flattens too.

See Pine Script webhook alerts for the full pattern, including the placeholder-in-dialog alternative for third-party scripts you don't author yourself.

Frequently Asked Questions

Which moving average is best for day trading?

The 9 EMA and 21 EMA on intraday timeframes are the most-used combination among futures day traders. The 200 EMA on the daily chart is the universal trend filter.

SMA vs EMA — does it really matter?

Yes, but not as much as traders think. SMA is smoother and slower; EMA is faster and more responsive. For short periods (under 20), EMA is usually the better choice. For long-term levels (50, 200), SMA and EMA behave very similarly.

What is the 'golden cross'?

The 50-day SMA crossing above the 200-day SMA. It's a widely-watched long-term bullish signal, though by the time it prints, the trend is usually well underway. The opposite — 50 below 200 — is the 'death cross.'

Can I trade just moving average crossovers?

You can, but win rates typically run 35–45% because crossovers lag. The edge comes from letting winners run — a pure crossover system relies on a few big trend trades to pay for many small whipsaw losses.