#### Previous topic

fynance.features.indicators.cci

#### Next topic

fynance.features.indicators.macd_hist

# fynance.features.indicators.hma¶

fynance.features.indicators.hma(X, w=21, kind='w', axis=0, dtype=None)

Compute the Hull Moving Average of size w for each X’ series’.

The Hull Moving Average, developed by A. Hull [3], is a financial indicator. It tries to reduce the lag in a moving average.

Parameters: X : np.ndarray[dtype, ndim=1 or 2] Elements to compute the indicator. If X is a two-dimensional array, then an indicator is computed for each series along axis. w : int, optional Size of the main lagged window of the moving average, must be positive. If w is None or w=0, then w=X.shape[axis]. Default is 21. kind : {‘e’, ‘s’, ‘w’} If ‘e’ then use exponential moving average, see ema for details. If ‘s’ then use simple moving average, see sma for details. If ‘w’ (default) then use weighted moving average, see wma for details. axis : {0, 1}, optional Axis along wich the computation is done. Default is 0. dtype : np.dtype, optional The type of the output array. If dtype is not given, infer the data type from X input. np.ndarray[dtype, ndim=1 or 2] Hull moving average of each series.

Notes

Let $$ma^w$$ the moving average function of lagged window size w.

$hma^w_t(X) = ma^{\sqrt{w}}_t(2 \times ma^{\frac{w}{2}}_t(X)) - ma^w_t(X))$

References

Examples

>>> X = np.array([60, 100, 80, 120, 160, 80])
>>> hma(X, w=3, dtype=np.float64)
array([ 60.        , 113.33333333,  76.66666667, 136.66666667,
186.66666667,  46.66666667])