#### Previous topic

fynance.features.indicators.hma

#### Next topic

fynance.features.indicators.macd_line

# fynance.features.indicators.macd_hist¶

fynance.features.indicators.macd_hist(X, w=9, fast_w=12, slow_w=26, kind='e', axis=0, dtype=None)

Compute Moving Average Convergence Divergence Histogram.

MACD is a trading indicator used in technical analysis of stock prices, created by Gerald Appel in the late 1970s . It is designed to reveal changes in the strength, direction, momentum, and duration of a trend in a stock’s price.

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 9. fast_w : int, optional Size of the lagged window of the short moving average, must be strictly positive. Default is 12. slow_w : int, optional Size of the lagged window of the lond moving average, must be strictly positive. Default is 26. kind : {‘e’, ‘s’, ‘w’} If ‘e’ (default) then use exponential moving average, see ema for details. If ‘s’ then use simple moving average, see sma for details. If ‘w’ 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] Moving average convergence/divergence histogram of each series.

References

Examples

>>> X = np.array([60, 100, 80, 120, 160, 80]).astype(np.float64)
>>> macd_hist(X, w=3, fast_w=2, slow_w=4)
array([ 0.        ,  5.33333333, -0.35555556,  3.93481481,  6.4102716 ,
-9.47070947])