Why smooth a price series at all#
Daily prices are noisy. A stock can drop 2% on Tuesday, recover 1.8% on Wednesday, and end the month exactly where it started. A moving average replaces each day's price with an average of recent prices, which filters the day-to-day jitter and leaves the underlying drift visible.
The cost is lag. Every moving average is built from past prices, so it turns after price turns. A shorter window reacts faster and whipsaws more. A longer window is smoother and slower. That tradeoff is the whole subject. There is no window length that removes noise without adding lag.
Pyx ships four averages: SMA, EMA, WMA, and VWAP. All four draw in price units on top of the chart, and all four start after a warm-up period because there is not enough history to fill the first window.
| Indicator | Pyx default | Weighting |
|---|---|---|
| SMA | 20 bars | Equal |
| EMA | 20 bars | Exponential decay |
| WMA | 20 bars | Linear |
| VWAP | None (cumulative) | By traded volume |
Simple moving average (SMA)#
The SMA is the unweighted mean of the last N closing prices.
Pyx leaves the first N - 1 bars empty, so a 20-bar SMA begins on bar 20. Every close inside the window counts equally, including the stale one about to roll off.
How to read it: the useful signal is the relationship between price and the line, not the line's level. Price holding above a rising SMA describes an uptrend. Price slicing below a flat long SMA describes a possible regime change. Slope matters more than position. A flat SMA in a sideways market carries no information.
The conventional settings are worth knowing because other people watch them: the 50-bar SMA for the intermediate trend and the 200-bar SMA for the long-term trend. The 50 crossing above the 200 is called a golden cross. The reverse is a death cross.
An SMA lags turning points by roughly half its window. A 20-bar SMA confirms a turn about 10 bars after it happened.
Exponential moving average (EMA)#
The EMA fixes the SMA's bluntest flaw, that a 20-day-old close counts as much as yesterday's. It blends each new close into the running average with a fixed smoothing factor, so old data fades geometrically instead of falling off a cliff.
Pyx seeds the first EMA value with the SMA of the first N closes, so the line starts from a stable level rather than a single bar. Because the formula is recursive, that seed influences every later value. Two charting tools that seed differently will disagree slightly forever.
How to read it: same as the SMA, but the EMA hugs price more closely and turns earlier. A 12-bar EMA crossing a 26-bar EMA is the raw material of MACD. Faster response is the same thing as more false signals in choppy markets. Pick one lag profile and accept its cost.
Weighted moving average (WMA)#
The WMA sits between the SMA and EMA. It weights the closes in its window linearly, newest heaviest, oldest lightest, then cuts off hard at the window edge.
The denominator is just the sum of the weights 1 through N. For a 20-bar WMA that is 210.
How to read it: like any moving average, through slope and price-versus-line. The WMA turns faster than an SMA of the same length because recent bars dominate. The hard cutoff has a quirk: one violent bar has outsized influence while it sits near the front of the window, then vanishes completely when it rolls off, which can make the line jump for no current reason.
Volume-weighted average price (VWAP)#
VWAP is different in kind. It answers a different question: at what average price has actual money changed hands. Each close is weighted by the volume that traded during that bar.
Pyx computes VWAP cumulatively from the first visible bar and never resets it. There are no parameters. The longer the series runs, the more inertia the line gathers, because each new bar is diluted by all the volume behind it.
Institutional desks invented VWAP as an execution benchmark. A buy filled below VWAP was a good fill. On a Pyx chart it works as a regime line: price trending above VWAP means recent buyers are ahead, price below means they are underwater.
Classic intraday VWAP resets every session. The cumulative form in Pyx is a longer-horizon reference, so do not compare it to a day trader's session VWAP.
What a crossover is worth#
A crossover happens when price crosses a moving average, or a fast average crosses a slow one. Crossovers are honest about trends and dishonest about everything else. In a trending market they get you in late but keep you in. In a sideways market price crosses the line again and again, and each cross looks like a signal. Those whipsaw signals cost more than they earn, which is the oldest documented failure mode in technical analysis.
Moving averages describe where price has been. None of them predict where it goes next. Use them to name the trend you are already looking at, not to forecast one.
Where to go next#
See how averages combine into an oscillator in RSI and MACD, or put one on a chart in the chart workspace. For the mechanics of chart types and scales, start with how to read a price chart.