coin-unknown / Indicators

Technical indicators for cryptocurrencies, stocks and forex. To work with historical and real price data. One of the most efficient Javascript library implementations. The library has such indicators as: Relative Strength Index (RSI), Moving Average C / D (MACD), Average Directional Index (ADX), Stochastic Oscillator, Bollinger Bands, Average True Range (ATR) and many others
377 stars 54 forks source link

RSI sometimes returns undefined instead of a RSI value #16

Closed gazsiazasz closed 2 years ago

gazsiazasz commented 2 years ago
let closes = [
    1.59,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.6,
    1.6,
    1.6,
    1.6,
    1.6,
    1.6,
    1.6,
    1.6,
]

let rsi = new RSI(14)
closes.forEach(c  => console.log(rsi.nextValue(c)))

Gives the following output instead of the real RSI values:

undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
100
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
BusinessDuck commented 2 years ago

That was a bug, that fixed with PR in master. Thank you @gazsiazasz for you report and code example