MACD exponential or weighted?

hello,

How is the MACD that Quantopian provides calculated?

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

Thank you,

Dante Migale

8 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)
``````

Wow! THANK YOU! <3

Do I have to place the matype part in the rest of the code as well? aka where the macd is used in handle data?

also what is the default if code is this:

def MACD(prices, fastperiod=65, slowperiod=105, signalperiod=45):
'''
Function to return the difference between the most recent
MACD value and MACD signal. Positive values are long
position entry signals

``````optional args:
fastperiod = 13
slowperiod = 21
signalperiod = 8

Returns: macd - signal
'''
macd, signal, hist = talib.MACD(prices,
fastperiod=fastperiod,
slowperiod=slowperiod,
signalperiod=signalperiod)
return macd[-1] - signal[-1]
``````

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

Yes but the default is exponential? And thank you so much!

yes, default is EMA