(df, n_fast, n_slow, price='Close')
return out(SETTINGS, df, result)
MACD, MACD Signal and MACD difference
MACD, MACD Signal and MACD difference
MACD MACD Signal and MACD difference
def MACD(df, n_fast, n_slow, price='Close'):
    """
    MACD, MACD Signal and MACD difference
    """
    EMAfast = pd.Series(df[price].ewm(span=n_fast, min_periods=n_slow - 1).mean())
    EMAslow = pd.Series(df[price].ewm(span=n_slow, min_periods=n_slow - 1).mean())
    MACD = pd.Series(EMAfast - EMAslow, name='MACD_%d_%d' % (n_fast, n_slow))
    MACDsign = pd.Series(MACD.ewm(span=9, min_periods=8).mean(), name='MACDsign_%d_%d' % (n_fast, n_slow))
    MACDdiff = pd.Series(MACD - MACDsign, name='MACDdiff_%d_%d' % (n_fast, n_slow))
    result = pd.DataFrame([MACD, MACDsign, MACDdiff]).transpose()
    return out(SETTINGS, df, result)
def MACD ( df , n_fast , n_slow , price = 'Close' ) : EMAfast = pd . Series ( df [ price ] . ewm ( span = n_fast , min_periods = n_slow - 1 ) . mean ( ) ) EMAslow = pd . Series ( df [ price ] . ewm ( span = n_slow , min_periods = n_slow - 1 ) . mean ( ) ) MACD = pd . Series ( EMAfast - EMAslow , name = 'MACD_%d_%d' % ( n_fast , n_slow ) ) MACDsign = pd . Series ( MACD . ewm ( span = 9 , min_periods = 8 ) . mean ( ) , name = 'MACDsign_%d_%d' % ( n_fast , n_slow ) ) MACDdiff = pd . Series ( MACD - MACDsign , name = 'MACDdiff_%d_%d' % ( n_fast , n_slow ) ) result = pd . DataFrame ( [ MACD , MACDsign , MACDdiff ] ) . transpose ( ) return out ( SETTINGS , df , result )