sey eeet
sey eeet

Reputation: 258

How to compute RSI on lower timeframe than the current timeframe?

I would like to plot the RSI for the lowertime frame compare to the timeframe that I am currently on. I then want to plot the current timeframe rsi and lower timeframe rsi in plots together. For the current rsi I have

rsi = ta.rsi(close, 14)
plot(rsi)

For lower timeframe rsi I have

arr_rsi = request.security_lower_tf(syminfo.tickerid, "60", ta.rsi(close, 14))

the issue is that arr_rsi is an array for each candle, lets say I compute the average of arr_rsi each time. How I can plot it using plot so it be on the same page with plot(rsi)?

Upvotes: 1

Views: 177

Answers (1)

vitruvius
vitruvius

Reputation: 21342

You can use the array.avg() function for that.

//@version=5
indicator("My script")

rsi = ta.rsi(close, 14)
plot(rsi, color=color.green)

arr_rsi = request.security_lower_tf(syminfo.tickerid, "1", ta.rsi(close, 14))
arr_rsi_avg = array.avg(arr_rsi)

plot(arr_rsi_avg, color=color.red)

enter image description here

Upvotes: 0

Related Questions