Standard MACD vs Talib MACD - Different Values
-
Talib MACD returns a different value than std MACD with re-sample data.
A report of @mr-m0nst3rUsing this example: https://gist.github.com/rodrigo-brito/4f779001647ce1ce7235a7d254b7e75b
With this dataset: https://github.com/rodrigo-brito/backtrader-binance-bot/blob/master/dataset/binance_nov_18_mar_19_btc.csvWithout re-sample, it is ok:
EMA12 = 6960.21 EMA26 = 6949.12 DIFF = 11.09 STD MACD = 11.09 TALIB MACD = 11.09 -------------- EMA12 = 6961.31 EMA26 = 6950.47 DIFF = 10.84 STD MACD = 10.84 TALIB MACD = 10.84 -------------- EMA12 = 6961.38 EMA26 = 6951.31 DIFF = 10.08 STD MACD = 10.08 TALIB MACD = 10.08 --------------
But, with a re-sample of 30 minutes, it returns a different value:
cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=30)
-------------- EMA12 = 7031.31 EMA26 = 7057.54 DIFF = -26.23 STD MACD = -26.23 TALIB MACD = -83.05 -------------- EMA12 = 7012.22 EMA26 = 7046.41 DIFF = -34.19 STD MACD = -34.19 TALIB MACD = -90.54 -------------- EMA12 = 7004.46 EMA26 = 7040.14 DIFF = -35.68 STD MACD = -35.68 TALIB MACD = -88.64 --------------
The graphic result is also different:
-
@Rodrigo-Brito said in Standard MACD vs Talib MACD - Different Values:
Talib MACD returns a different value than std MACD with re-sample data.
A good reason not to use
ta-lib
. -
@backtrader said in Standard MACD vs Talib MACD - Different Values:
on not to use ta-lib.
Hi @backtrader ,
there're differences with standard MACD after resample the data.
Reference: https://github.com/rodrigo-brito/backtrader-binance-bot/issues/3 -
Indeed. You seem to be extremely new to indicators, timeframes, periods and resampling.
ta-lib
has a problem with the implementation of indicators with an "unstable" period, because of a cumbersome implementation, which is easily solved (industry de-facto standard) by using a seed value.An "Exponential Moving Average" is an example, because the definition of that average is that of a first order infinite impulse response filter. All values are always taken into account which leads to a recursive definition for updating values in real-time.
Please read: https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
You can see that the problem is a
ta-lib
well-known issue: https://github.com/mrjbq7/ta-lib/issues/114Back to square one: a good reason not to use
ta-lib