RSI calculator for stocks workflow

Hi,

Please find a solution in the workflow attached.

I couldn’t use your workflow because the data was not available, but I used the workflow prepared by Gabriel here Need help (very new to this field) with some more realistic price data. I also added a counter to the data to show the day number using the Counter Generation node.

I first changed the upward and downward movements to percentages in the expressions inside the Math Formula nodes. Then I calculated the moving average over a period of 14 days using the Moving Average node.

Then I lagged these gains by one row using the Lag Column node.

Finally I calculated the first, second, etc. RSIs using the Column Expressions node with the following code inside:

day = column("Counter")
RSI = null

if (day = 15)
    RSI = 100 - (100/(1+(column("MA(Upward movement)")/14)/(column("MA(Downward Movement)")/14)))

if (day > 15)
    RSI = 100 - (100/(1+(column("MA(Upward movement)(-1)")*13+column("Upward movement"))/(column("MA(Downward Movement)(-1)")*13+column("Downward Movement"))))

RSI Calculation.knwf (18.2 KB)

Please check if the formulas are correct! Especially the division by 14 in the first RSI. I took the formula from here: https://www.investopedia.com/terms/r/rsi.asp

I hope this helps!

Maarit

2 Likes