Bitvested / ta.js

Financial Technical Analysis in JavaScript
MIT License
142 stars 33 forks source link

Can you explain why RSI returns an array? #14

Closed brandonros closed 2 years ago

brandonros commented 2 years ago

https://stackoverflow.com/questions/22626238/calculate-rsirelative-strength-index-using-some-programming-language-js-c

Should I just take 0th element?

brandonros commented 2 years ago

Dupe of https://github.com/Bitvested/ta.js/issues/7

Vultwo commented 2 years ago

Almost all functions return arrays to enable further manipulation. Lets say you want a signal line of the RSI, you just take the output of the function and enter it in a moving average with a length.

rsi = await ta.rsi(rsi_data, rsi_length);
signal = await ta.sma(rsi, ma_length);

To retrieve the latest value get the last array element.