TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.81k stars 1.78k forks source link

MFI、STOCHRSI are not correct in some cases #567

Open Caleblgx opened 2 years ago

Caleblgx commented 2 years ago

An interesting phenomenon in Python: image Code of MFI: image The problem is if tempValue1 = (2.86 + 2.7 + 2.73), prevValue = (2.81 + 2.7 + 2.78), which means tempValue2 not equal to 0(a small number instead due to the machine error), tempValue2 > 0. Obviously, the result is not what we want and far from the correct result. I have some advice and I don't know whether they make sense in all case.

  1. tempValue2 keep 8(or 10 whatever) decimal places.
  2. do some change in if statement: bigger/small than a number closes to 0 (just like TA_IS_ZERO)

The other problem is STOCHRSI: image The five numbers in the window are supposed to be same, but unfortunately they are not due to the machine error(I guess). Again, the result is far from the correct result. I think we can drop some accuracy to avoid machine error which can make result far away away from the correct result.

Thank you very much for answering in advance !

trufanov-nok commented 2 years ago

It might be a bug. There was similar problem with near 0 values in CCI: https://sourceforge.net/p/ta-lib/bugs/107/

mrjbq7 commented 1 year ago

This will be something to fix right away when we take over TA-Lib C library maintenance.