karlwancl / Trady

Trady is a handy library for computing technical indicators, and it targets to be an automated trading system that provides stock data feeding, indicator computing, strategy building and automatic trading. It is built based on .NET Standard 2.0.
https://lppkarl.github.io/Trady
Apache License 2.0
545 stars 184 forks source link

RSI returns null instead of 100 when there is no Average Loss #91

Open tht12837a opened 5 years ago

tht12837a commented 5 years ago

RSI should be 100 when the Average Loss equals zero. Using the RelativeStrengthIndexByTuple we should get 100 when there is no Average Loss, but instead RSI is null.

How to reproduce:

            List<decimal?> allTradyCandlesList = new List<decimal?>();

            for (int i = 1; i < 21; i++)
            {
                allTradyCandlesList.Add(i);
            }
            var rsi = new RelativeStrengthIndexByTuple(allTradyCandlesList, 10)[allTradyCandlesList.Count - 1];