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).

示例

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[源代码]

基类:MovingAverageBase

By 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))

备注

  • 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)
next()[源代码]

Calculate HMA for the current bar.

Formula: HMA = WMA(2*WMA(n/2) - WMA(n), sqrt(n))

once(start, end)[源代码]

Calculate HMA in runonce mode.

frompackages = ()
packages = ()
backtrader.indicators.hma.HMA

HullMovingAverage 的别名