Open paris0120 opened 2 years ago
Could you provide a direct links to the code lines you are comparing?
I don't think that it's publicly available. All the functions are in the core.class.
This is ADX code from TA-Lib C library, which is under the hood of this python wrapper:
https://github.com/TA-Lib/ta-lib/blob/master/src/ta_func/ta_ADX.c#L414
It contains:
prevMinusDM -= prevMinusDM/optInTimePeriod;
prevPlusDM -= prevPlusDM/optInTimePeriod;
All the functions are in the core.class.
Where I can find that core.class file?
I have no idea where it goes wrong but here is my worksheet. The results with talib for dx is array([ nan, nan, nan, nan, 100. , 58.70967742, 55.64929196, 71.1993739 , 71.1993739 , 26.23631438]) <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
h | 146.59 | 145.74 | 145.7 | 145.47 | 145.12 | 145.26 | 145.27 | 145.25 | 145.01 | 145.13 -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- l | 145.85 | 145.53 | 145.4 | 145 | 144.92 | 145 | 145.12 | 144.91 | 144.92 | 144.93 c | 146.2 | 145.58 | 145.47 | 145.12 | 145.03 | 145.11 | 145.25 | 144.98 | 144.98 | 145.1 tr | nan | 0.67 | 0.3 | 0.47 | 0.2 | 0.26 | 0.16 | 0.34 | 0.09 | 0.2 trsum | | | | | 581.2 | 581.01 | 581.0075 | 580.7356 | 580.5317 | 580.4988 atr | | | | | 145.3 | 145.2525 | 145.2519 | 145.1839 | 145.1329 | 145.1247 up | | -0.85 | -0.04 | -0.23 | -0.35 | 0.14 | 0.01 | -0.02 | -0.24 | 0.12 down | | 0.32 | 0.13 | 0.4 | 0.08 | -0.08 | -0.12 | 0.21 | -0.01 | -0.01 pdm | | 0 | 0 | 0 | 0 | 0.14 | 0.01 | 0 | 0 | 0.12 ndm | | 0.32 | 0.13 | 0.4 | 0.08 | 0 | 0 | 0.21 | 0 | 0 psum | | | | | 0 | 0.14 | 0.115 | 0.08625 | 0.064688 | 0.168516 nsum | | | | | 0.93 | 0.6975 | 0.523125 | 0.602344 | 0.451758 | 0.338818 pdi | | | | | 0 | 0.000241 | 0.000198 | 0.000149 | 0.000111 | 0.00029 ndi | | | | | 0.0016 | 0.0012 | 0.0009 | 0.001037 | 0.000778 | 0.000584 dx | | | | | 100 | 66.56716 | 63.9569 | 74.94894 | 74.94894 | 33.56817
I'm developing a similar library and testing the results with this lib (https://github.com/paris0120/talibjs.git ). I find that there might be some calculation errors. I compare the results with the python version and look into the algorithm in Java. For example ADX, line 524 525:
I believe that they should be
I also got different results with ATR. However, both the trueRange and SMA function work correctly but the ATR doesn't have the correct number. (I calculated manually to verify that my version has the correct number).