opened
stefankirchfeld
username_0
Since these fields are not only result fields but are also used internally for the i+1 calculations for the next period, and they are rounded, the average gain remains the same for a lot of periods over time, although smaller gains/losses occurred, which actually do affect the RSI.
Hence the indicator tends to deliver values that are too low.

I did not check if similar rounding errors happen for other indicators as well, maybe it's worth going over your code again and double check this.

I would suggest to not round any fields that are used for in-between calculations. Only at the very end, just when the data is returned to the caller, fields can be rounded.

I noticed the discrepancies when comparing your RSI values with RSIs for example on tradingview.com or results delivered from another node library (@d3fc/d3fc-technical-indicator). 

Best regards,
Stefan
Wrong RSI calculations due to rounding errors
issue
created
mdkrieg
username_1
Hello @username_0 

I've forked this repository and fixed the issue you mentioned. I increased the rounding to 10 decimals and fixed a problem with the intial averages including the first bar which is always zero gain & loss.

See here: https://github.com/username_1/alphacate

@codeplayr , big thanks and nice work on this repository!

Regards,
-Matt
comment