Language: English. Choose a language
Get started

← All tools

Free tools

Indicator lag lab

Every moving average trades smoothness for lag: the more past prices it averages, the calmer its line and the later it turns. This lab draws four kinds of average over the same simulated price series, at a length you choose, and measures how far each trails the series and how much of the series’ bar-to-bar jitter it keeps.

Sets the simulated series; the same seed always gives the same one.

Averages shown

Simple moving average—
Exponential moving average—
Weighted moving average—
Hull moving average—

The simulated series with the averages shown.

SIMULATED data: a random walk indexed from 100, in which every bar’s return is drawn with an average of zero. No real instrument is shown, and nothing here is a result of trading.

How it works

The series has 1,000 bars; the chart shows the last 300. All four averages use the length you choose. The simple average (SMA) weighs every bar in its window equally. The exponential average (EMA) weighs each older bar a fixed fraction less, with α = 2 ÷ (length + 1). The weighted average (WMA) weighs the newest bar by the length and the oldest by 1. The Hull average takes twice a WMA of half the length, subtracts a WMA of the full length, and smooths the result with a WMA of the square root of the length.

The two figures

Lag is measured: the number of bars the series has to be moved later so that it lines up best with the average, by the smallest mean squared gap. Beneath it is the lag by construction, the average age of the prices the average weighs: (length − 1) ÷ 2 for SMA and EMA and (length − 1) ÷ 3 for WMA, while Hull’s subtraction cancels most of it. Construction lag is exact on a straight-line trend; on a wandering series the measured lag differs, especially for EMA, whose oldest weights reach far back.

Roughness compares how much the average’s slope changes from bar to bar with how much the series’ slope does, as a percentage. 100% is as jittery as the series; lower is smoother. Both figures are taken over the same bars for every average.

What it shows, and what it doesn’t

Longer lengths smooth more and trail further; Hull trails far less than the others at the same length and keeps more of the jitter. No setting removes both. The figures describe these constructions on one simulated series; they say nothing about which length or kind suits any market. The indicator reference describes each average and its inputs in full.