Closed dsiens closed 3 years ago
Hello, I thing MACD zero lag calculation is not the correct one, I don't have any match with a TradingView MACD 0 lag chart.
I used to made it work with DEMA formula, perfect match with TradingView. This made me work my Python :)
You can used it:
def get_DEMA(prices, maPeriod, prec=8): EMA1 = get_EMA(prices, maPeriod) EMA2 = get_EMA(EMA1, maPeriod) DEMA = np.subtract ((2 * EMA1[:len(EMA2)]), EMA2) return DEMA.round(prec)
def get_zeroLagMACD(prices, Efast=12, Eslow=26, signal=9): z1 = get_DEMA (prices, Efast) z2 = get_DEMA (prices, Eslow) lineMACD = np.subtract (z1[:len(z2)], z2) lineSIGNAL = get_DEMA (lineMACD, signal) histogram = np.subtract(lineMACD[:len(lineSIGNAL)], lineSIGNAL) return [({ "macd":float("{0}".format(lineMACD[i])), "signal":float("{0}".format(lineSIGNAL[i])), "hist":float("{0}".format(histogram[i]))}) for i in range(len(lineSIGNAL))]
Thank you very much for this solution, I will add this ASAP
Added in new version also added comment thanking you for logic fix.
Hello, I thing MACD zero lag calculation is not the correct one, I don't have any match with a TradingView MACD 0 lag chart.
I used to made it work with DEMA formula, perfect match with TradingView. This made me work my Python :)
You can used it: