RSI公式显示略有错误的结果

时间:2018-08-15 09:26:51

标签: java graph bitcoin

这是RSI图的两张图片。他们俩都需要8天。我使用的公式(取自stackoverflow的另一个问题):

    public static double CalculateRsi(List<Double> closePrices)
{

    double sumGain = 0;
    double sumLoss = 0;
    for (int i = 1; i < closePrices.size(); i++)
    {
        double difference = closePrices.get(i) - closePrices.get(i-1);
        if (difference >= 0)
        {
            sumGain += difference;
        }
        else
        {
            sumLoss -= difference;
        }
    }

    if (sumGain == 0) return 0;

    double relativeStrength = sumGain / sumLoss;

    return 100.0 - (100.0 / (1 + relativeStrength));
}

Good RSI

Bad RSI

为什么我的程序显示的结果略有不同?

0 个答案:

没有答案