bukosabino / ta

Technical Analysis Library using Pandas and Numpy
https://technical-analysis-library-in-python.readthedocs.io/en/latest/
MIT License
4.25k stars 868 forks source link

RSI, StochRSI, Bollinger Bands issue #275

Open chdragan opened 2 years ago

chdragan commented 2 years ago

Hello, Greetings and thank you for implementing this library. I used your library and was able to compare live the values for RSI and Stochastic RSI (K,D) with other software. I noticed differences and I extracted data from TradingView and compared the results. As you can see RSI, K,D are Bollinger Bands are different. Best regards

TradingView: RSI 49.0394593224667 K 11.5673529700911 D 21.3072238952219 Bollinger Band High 0.852205319882761 Bollinger Band Lower 0.851892680117259

  Close    rsi         k         d  bol_h     bol_l

0 0.85138 NaN NaN NaN 0.0 NaN 1 0.85142 NaN NaN NaN 0.0 NaN 2 0.85135 NaN NaN NaN 0.0 NaN 3 0.85139 NaN NaN NaN 0.0 NaN 4 0.85129 NaN NaN NaN 0.0 NaN 5 0.85134 NaN NaN NaN 0.0 NaN 6 0.85146 NaN NaN NaN 0.0 NaN 7 0.85150 NaN NaN NaN 0.0 NaN 8 0.85165 NaN NaN NaN 0.0 NaN 9 0.85186 NaN NaN NaN 0.0 NaN 10 0.85148 NaN NaN NaN 0.0 NaN 11 0.85151 NaN NaN NaN 0.0 NaN 12 0.85152 NaN NaN NaN 0.0 NaN 13 0.85152 54.07 NaN NaN 0.0 NaN 14 0.85157 56.83 NaN NaN 0.0 NaN 15 0.85154 54.71 NaN NaN 0.0 NaN 16 0.85158 57.01 NaN NaN 0.0 NaN 17 0.85151 52.02 NaN NaN 0.0 NaN 18 0.85150 51.33 NaN NaN 0.0 NaN 19 0.85152 52.68 NaN NaN 0.0 0.851131 20 0.85153 53.38 NaN NaN 0.0 0.851147 21 0.85148 49.45 NaN NaN 0.0 0.851154 22 0.85141 44.50 NaN NaN 0.0 0.851167 23 0.85144 46.95 NaN NaN 0.0 0.851176 24 0.85156 55.42 NaN NaN 0.0 0.851225 25 0.85155 54.64 NaN NaN 0.0 0.851263 26 0.85189 70.11 NaN NaN 0.0 0.851204 27 0.85195 71.93 NaN NaN 0.0 0.851145 28 0.85215 76.96 NaN NaN 0.0 0.851032 29 0.85199 66.66 NaN NaN 0.0 0.851007 30 0.85194 63.79 NaN NaN 0.0 0.851000 31 0.85193 63.20 NaN NaN 0.0 0.850999 32 0.85199 65.27 NaN NaN 0.0 0.850994 33 0.85220 71.33 NaN NaN 0.0 0.850957 34 0.85211 66.01 NaN NaN 0.0 0.850948 35 0.85208 64.29 NaN NaN 0.0 0.850958 36 0.85209 64.62 NaN NaN 0.0 0.850967 37 0.85200 59.30 NaN NaN 0.0 0.851005 38 0.85204 60.84 NaN NaN 0.0 0.851050 39 0.85202 59.62 NaN NaN 0.0 0.851099 40 0.85195 55.44 0.475251 NaN 0.0 0.851155 41 0.85198 56.84 0.437024 NaN 0.0 0.851234 42 0.85204 59.57 0.421879 0.444718 0.0 0.851357 43 0.85213 63.32 0.437381 0.432095 0.0 0.851494 44 0.85214 63.72 0.445747 0.435002 0.0 0.851608 45 0.85209 60.16 0.362437 0.415188 0.0 0.851786 46 0.85215 62.85 0.325890 0.378025 0.0 0.851810 47 0.85203 54.89 0.176710 0.288346 0.0 0.851823 48 0.85213 59.49 0.192658 0.231753 0.0 0.851825 49 0.85194 49.22 0.085159 0.151509 0.0 0.851815

fxhuhn commented 2 years ago

There are different calculation methods for RSI. See https://www.macroption.com/rsi-calculation/

Most common are Simple Moving Average (this is often used in charting apps) and the Exponential Moving Average (used by this package)

Can you check this out?