nardew / talipp

talipp - incremental technical analysis library for python
https://nardew.github.io/talipp
MIT License
367 stars 59 forks source link

ALMA - discrepancy between talipp and tradingview #128

Closed filipemarques87 closed 4 months ago

filipemarques87 commented 5 months ago

First of all, congratulation for this library, it is really cool for realtime processing.

I was checking the ALMA indicator and I noticed some discrepancy between this library and tradingview.

I did some tests and update the code to this, the results are now the same

s = self.period / self.sigma # s = self.period / float(self.sigma) -> no need the float cast
m = (self.period - 1) * self.offset # m = int((self.period - 1) * self.offset) -> the int cast is truncating the decimal part
nardew commented 4 months ago

Hi, thanks for the proposal.

Ad s, the float cast is needed if sigma is an integer. Ad m, I found it like this somewhere but not sure where. Even trading view says //m = math.floor(offset * (windowsize - 1)) // Used as m when math.floor=true though I am not 100% sure what they mean (how does one set math.floor to true?)

If I remove flooring for m, indeed I get the same results as in trading view. I will do this change. Thanks.

nardew commented 4 months ago

Delivered in 2.2.1.