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 [4]. 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
orw=0
, thenw=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’}
- 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.
Returns: - np.ndarray[dtype, ndim=1 or 2]
Moving average convergence/divergence histogram of each series.
See also
References
[4] https://en.wikipedia.org/wiki/MACD 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])