signal_line

Defined in fynance.features.indicators

signal_line(X, w=9, fast_w=12, slow_w=26, kind='e', axis=0, dtype=None)[source]

MACD Signal Line for window of size w with slow and fast lenght.

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:
Xnp.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.

wint, 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_wint, optional

Size of the lagged window of the short moving average, must be strictly positive. Default is 12.

slow_wint, 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.

dtypenp.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]

MACD signal line of each series.

See also

z_score, bollinger_band, hma, macd_hist, macd_line, cci

References

Examples

>>> X = np.array([60, 100, 80, 120, 160, 80]).astype(np.float64)
>>> signal_line(X, w=3, fast_w=2, slow_w=4)
array([ 0.        ,  5.33333333,  4.97777778,  8.91259259, 15.3228642 ,
        5.85215473])