Hull moving average
All indicators

LibraryTrend

Indicator

Hull moving average

Alan Hull's moving average, built to follow price with little lag while staying smooth.

TrendOn the price2 inputsHMA

How it is calculated

Two WMAs of the source, one over half the length (rounded down), one over the full length. Twice the short one minus the long one cancels most of the lag, and that difference is smoothed again with a WMA over the square root of the length, rounded down. The first value needs length plus that root minus 1 bars.

Reference: Hull 2005

How to read it

The direction of the line is the main reading: a turn shows a change of trend early. Because it removes lag by extrapolating, it overshoots at sharp turns and can run past price; in a sideways market it turns often.

In a strategy

The slope as trend signal: compare ctx.ind("hma", length=21) with its value a bar earlier and hold longs while it rises.

Inputs

InputTypeDefaultRange or choices
LengthlengthWhole number9min 2, max 5000
SourcesourcePrice"close"close, open, high, low, hl2, hlc3, ohlc4, hlcc4

What it draws

LineDrawn as
HMALine

Used in

No strategy template reads it yet.

OrionQuant