macd#

API documentation for pandas_ta.momentum.macd Python function.

macd(close, fast=None, slow=None, signal=None, talib=None, offset=None, **kwargs)[source]#

Moving Average Convergence Divergence (MACD)

The MACD is a popular indicator to that is used to identify a security’s trend. While APO and MACD are the same calculation, MACD also returns two more series called Signal and Histogram. The Signal is an EMA of MACD and the Histogram is the difference of MACD and Signal.

Sources:

https://www.tradingview.com/wiki/MACD_(Moving_Average_Convergence/Divergence) AS Mode: https://tr.tradingview.com/script/YFlKXHnP/

Calculation:
Default Inputs:

fast=12, slow=26, signal=9

EMA = Exponential Moving Average MACD = EMA(close, fast) - EMA(close, slow) Signal = EMA(MACD, signal) Histogram = MACD - Signal

if asmode:

MACD = MACD - Signal Signal = EMA(MACD, signal) Histogram = MACD - Signal

Args:

close (pd.Series): Series of ‘close’s fast (int): The short period. Default: 12 slow (int): The long period. Default: 26 signal (int): The signal period. Default: 9 talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib

version. Default: True

offset (int): How many periods to offset the result. Default: 0

Kwargs:
asmode (value, optional): When True, enables AS version of MACD.

Default: False

fillna (value, optional): pd.DataFrame.fillna(value) fill_method (value, optional): Type of fill method

Returns:

pd.DataFrame: macd, histogram, signal columns.