New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible RSI bug #1116
Comments
In what scenario would both the average gain and average loss both be zero? Periods with price losses are counted as zero for the average gain term, and periods with price gains are counted as zero for the average loss term. For both terms to be zero it would mean there was a price gain and loss within the same period which is contradictory. I view the existing fail safe code of:
as returning a "something is wrong" signal rather than a real RSI value, I know I would if I saw an RSI of 0 or 100. Returning 50 would mask such underlying problems resulting in false signals. |
An alternative is to return NaN, making the "exception"explicit. Any other suggestions? |
I think it would be more logical to return 50, since for the same infinitesimal averageLoss and averageGain it returns 50. |
While there may be little to no difference on a number line, in this case it's quite literally the difference between valid and invalid. Silently swallowing signs you have something deeply wrong and instead presenting a business-as-usual signal is a poor approach, especially when there's money on the line. |
Why do you consider the situation when both averageGain and averageLoss are zero invalid? |
After mulling this over I've come around to returning 50 in this scenario. @jorkey would you mind creating a PR? |
Unfortunately, I can't edit XLS on my Mac. This is necessary to correct the test data. |
When averageLoss.isZero() and averageGain.isZero() RSI returns zero.
RSI must return 50 when averageLoss equals averageGain.
For loss 0.001 and gain 0.001 it returns 50, but for zeros values it returns zero.
I think it's illogical.
The text was updated successfully, but these errors were encountered: