anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.2k stars 566 forks source link

RSI Input Values #234

Open EatsJE opened 3 years ago

EatsJE commented 3 years ago

Hi! Firstly, thanks for developing an awesome package!

Its a bit of a stupid question, but I can't find the answer in any docs/issues. What are the input vales for RSI?

const rsi = require('technicalindicators').rsi;

rsi({????});

The Binance API returns 15 day price data (to calc 14d RSI) in the below format, what calculation needs to be made before passing into the rsi() function?

[ [ 1499040000000, // Open time "0.01634790", // Open "0.80000000", // High "0.01575800", // Low "0.01577100", // Close "148976.11427815", // Volume 1499644799999, // Close time "2434.19055334", // Quote asset volume 308, // Number of trades "1756.87402397", // Taker buy base asset volume "28.46694368", // Taker buy quote asset volume "17928899.62484339" // Ignore. ] ]

Thank you! :)

rlmomin commented 3 years ago

@EatsJE The link provides an example on how to use the calculation: https://runkit.com/anandaravindan/rsi

The RSI can be calculated on any type of value, in my case I use the close price. Create an Object with keys, values and period. Values should be an array of 'close' prices or whatever you choose. The period should be the RSI period you want to evaluate. Keep in mind that RSI calculation requires n+1 values, a 14-day period requires 15 values in the array.

Pass the object into rsi.calculate(your_object). Keep in mind that your array[0] is the oldest data. I believe there is a 'reverse' parameter you can pass into the object as either true or false. This would account for your input array having the latest value at index 0.