Trading glossary

Moving average

By the PatternX team · Published

Definition

A moving average is the average price over a fixed number of recent periods, recalculated with each new bar. A simple moving average weights every period equally; an exponential moving average weights recent prices more.

Also called: SMA, EMA

How it's measured

The simple moving average (SMA) over n periods is the sum of the last n closing prices divided by n. Each new bar adds one price and drops the oldest.

The exponential moving average (EMA) uses a smoothing factor k = 2 ÷ (n + 1):

For a 20-period EMA, k = 2 ÷ 21 ≈ 0.095, so the latest price carries about 9.5% of the weight and older prices fade gradually. That makes the EMA quicker to react than an SMA of the same length, but also more prone to false turns in choppy markets.

Typical lengths are 9–21 periods for the short-term trend, 50 for the intermediate trend and 200 for the long-term trend on daily charts. Pairs such as 12/26 (the basis of MACD) and 20/50 are used to judge trend direction.

Why it matters

A moving average smooths out noise so the trend is easier to see. Price above a rising average, or a fast average above a slow one, is a simple working definition of an uptrend. Widely watched averages can also act as dynamic support and resistance. The cost is lag: an average confirms a trend only after part of it has happened.

Example

For example, closes of $10, $11, $12, $11 and $13 give a 5-period SMA of $57 ÷ 5 = $11.40. For a 5-period EMA, k = 2 ÷ 6 ≈ 0.333. If yesterday's EMA was $11.20 and today's close is $13, the new EMA is (13 × 0.333) + (11.20 × 0.667) ≈ $11.80, closer to the latest price than the SMA.

Common mistakes

  • Treating crossovers as precise signals. Averages lag by design, so crossovers often arrive after much of the move.
  • Optimizing the length to past data. A setting that fit last year perfectly may not fit next year.
  • Relying on averages in ranges. In sideways markets, price whips back and forth through them.

How PatternX uses it

In PatternX, exponential moving averages feed the scoring and context layers. The PatternX Score gives 10% of its weight to trend alignment, judged with the 20- and 50-period EMAs, and a separate 7% factor checks whether the next timeframe up agrees (multi-timeframe analysis). PatternX AI's trend-strength factor compares the 12- and 26-period EMAs; see the AI context layer.

Related reading