markcheno / go-talib

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

Query on plus_di (and similar functions) #22

Closed icecolbeveridge closed 2 years ago

icecolbeveridge commented 2 years ago

https://github.com/markcheno/go-talib/blob/cd53a9264d70bedcff891f59bf153275f524c100/talib.go#L2500

Hello,

I wanted to check the maths on the DI implementation -- I think there might be an off-by-one error in how it's set up. I would expect the first values of prevTR and prevPlusDM to be the sum of the first (period) readings rather than the first (period - 1) -- otherwise these values are systematically under-weighted and (I believe) the ratio converges to the correct value more slowly.

It's more than possible that I've made an error or misunderstood, but thought I ought to flag it up.

Many thanks.

markcheno commented 2 years ago

There very well may be a bug, but I test the output against the official TaLib and it matches. Therefore I am hesitant to make any changes. Thanks for the heads up.

icecolbeveridge commented 2 years ago

Understood, thanks Mark.

On Sat, 12 Mar 2022 at 13:33, Mark Chenoweth @.***> wrote:

Closed #22 https://github.com/markcheno/go-talib/issues/22.

— Reply to this email directly, view it on GitHub https://github.com/markcheno/go-talib/issues/22#event-6229734694, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJGYIQ3FZ5U3R2Q5B2ETZ3U7SMMBANCNFSM5QPNOI2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>