Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
MACD exponential or weighted?

hello,

How is the MACD that Quantopian provides calculated?

Is it exponential, weighted, wilders, what?!?

4 responses

You may choose whatever you want.

def MACD(prices, fastperiod=9, fastmatype=1, slowperiod=80, slowmatype=1, signalperiod=3, signalmatype=1):  
    macd, signal, hist = talib.MACDEXT(prices,  
                                       fastperiod=fastperiod,  
                                       slowperiod=slowperiod,  
                                       signalperiod=signalperiod,  
                                       fastmatype=fastmatype,  
                                       slowmatype=slowmatype,  
                                       signalmatype=signalmatype)  
    return macd[-1]

# list of values for the Moving Average Type:  
#0: SMA (simple)  
#1: EMA (exponential)  
#2: WMA (weighted)  
#3: DEMA (double exponential)  
#4: TEMA (triple exponential)  
#5: TRIMA (triangular)  
#6: KAMA (Kaufman adaptive)  
#7: MAMA (Mesa adaptive)  
#8: T3 (triple exponential T3)  

You do not need .
But you may try whatever you want:

def MA(prices, maperiod=9, matype=1):  
    ma = talib.MA(prices, maperiod=maperiod,matype=matype)  
    return ma[-1]


Tipical settings are EMA 12, EMA 26, EMA 9.
Good place to find more about MACD