Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Standard MACD vs Talib MACD - Different Values

    General Discussion
    3
    4
    2746
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Rodrigo Brito
      Rodrigo Brito last edited by

      Talib MACD returns a different value than std MACD with re-sample data.
      A report of @mr-m0nst3r

      Using 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.csv

      Without 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:

      alt text

      B 1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators @Rodrigo Brito last edited by

        @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.

        mr-m0nst3r 1 Reply Last reply Reply Quote 1
        • mr-m0nst3r
          mr-m0nst3r @backtrader last edited by

          @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

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by

            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/114

            Back to square one: a good reason not to use ta-lib

            1 Reply Last reply Reply Quote 1
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors