Moving AveragesPine Script v6

ta.hma()Hull Moving Average

Computes the Hull Moving Average (HMA), designed to reduce lag while keeping the line smooth by combining weighted moving averages with a square-root length step. Useful when you want a responsive trend line.

Syntax

Syntax
ta.hma(source, length) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries of values to process.
lengthsimple intHMA length.

Returns

Hull moving average of source for length bars back.

Remarks

na values in the source series are ignored.

Code Examples

Pine Script v6 Example
//@version=6
indicator("Hull Moving Average")
src = input(defval=close, title="Source")
length = input(defval=9, title="Length")
hmaBuildIn = ta.hma(src, length)
plot(hmaBuildIn, title="Hull MA", color=#674EA7)

Trading Applications

Minimize lag while maintaining smoothness

Identify trend reversals earlier than traditional MAs

Use for fast-moving market scalping strategies

Combine with other MAs for crossover signals

Frequently Asked Questions

ta.hma() is the built-in Hull Moving Average. It applies WMA steps (including half-length and sqrt-length phases) to approximate the current trend with less lag than a plain SMA of the same nominal length.

The Hull method deliberately corrects for lag introduced by smoothing: it combines WMAs so the result tracks turning points more quickly while still filtering noise better than a very short SMA.

Common uses include slope and direction of the HMA (up vs down), price relative to HMA for bias, and crossovers between HMA and price or another MA. Always validate signals with your timeframe and risk rules.

Generate ta.hma() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.hma() and other built-in functions instantly.