anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.13k stars 550 forks source link

incorrect calculator RSI #216

Open sajadonline opened 4 years ago

sajadonline commented 4 years ago

hi i used rsi for calculator

const rsi = require('technicalindicators').RSI prices = [4261,4689,4400,6463,9837,13715,10285,10325] // first transaction from binance BTC var period = 3 var cal = rsi.calculate({period : period, values : prices})

when i comparison this number and rsi binance is very incorrect

code result : [ 89.6, 96.31, 98.26, 57.84, 58.14 ] //binance persent rsi period 3 from 2017/08/01 time frame 1 month 94,97,58,58,30

please help me

Vasile-Peste commented 4 years ago

I am also getting completely different results compared to other online tools/brokers... UP.

oscarmoutinho commented 4 years ago

Also different from tradingview.com RSI.

adsonvinicius commented 3 years ago

So is this indicator is not true reliable at all?

rlmomin commented 3 years ago

Indicator works. I have a database with over 4000 symbols with 20yrs+ data. I just checked my results against values in thinkorswim and are accurate to 1/100th.

adsonvinicius commented 3 years ago

@rlmomin thanks by your info. I was checking this library issues and I could see some questions about the indicators results. Of course there are people's mistakes or misunderstandings about how to check and interpret values so I was looking for responses like yours.

oscarmoutinho commented 3 years ago

I think there are different views about the calculation rules. For tradingview.com RSI equivalence, I recreated RSI calc (AverageGain/AverageLoss) using WEMA (RMA). Something like: _rsi(x, y) => u = max(x - x[1], 0) // upward change d = max(x[1] - x, 0) // downward change rs = rma(u, y) / rma(d, y) res = 100 - 100 / (1 + rs) res

sajuuk31 commented 3 years ago

I think there are different views about the calculation rules. For tradingview.com RSI equivalence, I recreated RSI calc (AverageGain/AverageLoss) using WEMA (RMA). Something like: _rsi(x, y) => u = max(x - x[1], 0) // upward change d = max(x[1] - x, 0) // downward change rs = rma(u, y) / rma(d, y) res = 100 - 100 / (1 + rs) res

Hello, I was having the same issue as the OP and tried your method (using WEMA with rsiPeriod and EMA with 1/rsiPeriod. It provided me with the same result as the original RSI from this package. Do you have any idea?

yovanoc commented 3 years ago

Could someone send a PR to have this RSI like tradingview?

saru2020 commented 3 years ago

I think there are different views about the calculation rules. For tradingview.com RSI equivalence, I recreated RSI calc (AverageGain/AverageLoss) using WEMA (RMA). Something like: _rsi(x, y) => u = max(x - x[1], 0) // upward change d = max(x[1] - x, 0) // downward change rs = rma(u, y) / rma(d, y) res = 100 - 100 / (1 + rs) res

What's 'x' here? @oscarmoutinho

I don't see this working:

Screenshot 2021-06-20 at 11 15 06 PM

Inputs please! [Btw, I'm relatively new to this arena]

saru2020 commented 1 year ago

I've found that the RSI works when all the data are given at once meaning don't feed in only period+1 or limited data per se, just input the whole list of values and the RSI indicator precisely matches the values in TV, it just works beautifully.