markcheno / go-talib

A pure Go port of TA-Lib (http://ta-lib.org)
MIT License
763 stars 213 forks source link

Macd calculation isn't correct #13

Closed loeffel-io closed 5 years ago

loeffel-io commented 5 years ago

Hey, i get a different result if i use your macd func with the example data from here

data:

[]float64{
                81.59,
                81.06,
                82.87,
                83.00,
                83.61,
                83.15,
                82.84,
                83.99,
                84.55,
                84.36,
                85.53,
                86.54,
                86.89,
                87.77,
                                87.29,
            },

result:

[0 0 0 0 0 0 0 0 0 0 0 0.9434874256972989 0.9025802469135868 0.9862497078697317 0.6256763196667094]

[0 0 0 0 0 0 0 0 0 0 0 0.1886974851394598 0.3314740374942852 0.46242917156937446 0.49507860118884145]

[0 0 0 0 0 0 0 0 0 0 0 0 0.5711062094193016 0.5238205363003572 0.130597718477868]
markcheno commented 5 years ago

Tuplip indicators may be calculating the macd or moving averages slightly differently or perhaps you are using a different type of moving average?

This library is a direct port of ta-lib and has tests that verify the results match up with ta-lib exactly (including macd).

loeffel-io commented 5 years ago

why they should calculate the macd or moving averages slightly differently? I am calculating the values by talib.Macd(data, 2, 5, 9).

markcheno commented 5 years ago

Some people use different moving average types. The standard macd used ema, but ta-lib also has MacdExt which allows different moving average types to be used in the calculation. Just an idea. I have no idea what tulip is using. All I can say is that the results match the original ta-lib.

loeffel-io commented 5 years ago

Ok, thank you