Hull Moving Average

The Hull Moving Average (HMA) of Alan Hull (2005) combines weighted moving averages of different lengths to remove almost all lag while staying smooth.

The formula for the Hull Moving Average first takes twice the WMA over half the window minus the WMA over the whole window of n periods, which extrapolates the price as the DEMA does:

\[\text{Raw HMA} = 2 \cdot \text{WMA}\left(\text{Close}, \left\lfloor \frac{n}{2}\right\rfloor\right) - \text{WMA}(\text{Close}, n)\]

A WMA over the square root of n periods then smooths that line:

\[\text{HMA} = \text{WMA}\left(\text{Raw HMA}, \left\lfloor \sqrt{n}\right\rfloor\right)\]

Where WMA(x, k) is the weighted moving average of x over k periods. Hull reads the direction of the HMA as the trend: a rising HMA an uptrend, a falling HMA a downtrend, with a turn of the HMA as the signal. Like the DEMA it overshoots the price after a sharp move.

A moving average smooths the price by averaging it over the last n periods, so that the trend shows through the noise of single periods. It is the oldest and most widely used trend indicator: the direction of the average shows the direction of the trend, the price above (below) it an uptrend (downtrend), and other indicators, from the MACD to the Bollinger Bands, are built on it. Every moving average trades smoothness against lag: the more periods it averages, the smoother it is and the later it turns after the price. The averages differ in how they weight the prices within the window and whether they adapt their speed to the market, each a different answer to that trade-off.

Also known as: HMA, Hull MA.

In the Finance Toolkit this is get_moving_average with method="hull", the same function as Moving Average.

Example · ^GSPC · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_moving_average:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["^GSPC"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_moving_average(method="hull", window=50)

Which returns:

References

  • Paper Hull, A. (2005). “Hull Moving Average.”
  • Library Referenced against TA-Lib’s HMA (Hull Moving Average)
Share