backtrader.indicators.hma module¶
HMA Indicator Module - Hull Moving Average.
This module provides the HMA (Hull Moving Average) indicator developed by Alan Hull to reduce lag while maintaining smoothness.
- Classes:
HullMovingAverage: HMA indicator (aliases: HMA, HullMA).
Example
- class MyStrategy(bt.Strategy):
- def __init__(self):
self.hma = bt.indicators.HMA(self.data.close, period=30)
- def next(self):
- if self.data.close[0] > self.hma[0]:
self.buy()
- class backtrader.indicators.hma.HullMovingAverage[source]¶
Bases:
MovingAverageBaseBy Alan Hull
The Hull Moving Average solves the age-old dilemma of making a moving average more responsive to current price activity whilst maintaining curve smoothness. In fact, the HMA almost eliminates lag altogether and manages to improve smoothing at the same time.
- Formula:
hma = wma(2 * wma(data, period // 2) - wma(data, period), sqrt(period))
Note
Please note that the final minimum period is not the period passed with the parameter period. A final moving average on moving average is done in which the period is the square root of the original.
In the default case of 30, the final minimum period before the moving average produces a non-NAN value is
34
- alias = ('HMA', 'HullMA')¶
- __init__(*args, **kwargs)¶
- frompackages = ()¶
- packages = ()¶
- backtrader.indicators.hma.HMA¶
alias of
HullMovingAverage