Sidechair

ta.hma()

Browse the reference

Returns the Hull moving average, built from weighted averages to cut lag while staying smooth.

Try it in the editor

ta.hma computes wma(2 * wma(source, length / 2) - wma(source, length), round(sqrt(length))). The first part overshoots toward recent prices and the outer average smooths the result.

The half length is rounded down, with a floor of 1. The first value appears on bar number length + round(sqrt(length)) - 1.

Syntax

Pine Script
ta.hma(source: series int/float, length: simple int) -> series float

Arguments

NameTypeDefaultDescription
sourceseries int/floatrequiredSeries of values to smooth.
lengthsimple intrequiredMain window length. A whole number of 1 or more.

Returns

series float: the Hull moving average, or na while the nested windows are still filling.

Remarks

  • A Hull average turns sooner than ta.sma and ta.ema of the same length but can overshoot after sharp moves.

Example

Pine ScriptHull average with a slope colourOpen in editor
//@version=6
indicator("Hull MA", overlay = true)
hull = ta.hma(close, 21)
plot(hull, "HMA", color = hull > hull[2] ? color.green : color.red, linewidth = 2)

See also

Runs on Sidechair