I use this code for timeframe 5 minutes
rsi5m = request.security(syminfo.tickerid, "5", ta.rsi(rsiSourceInput, rsiLengthInput))
rsi15m = request.security(syminfo.tickerid, "15", ta.rsi(rsiSourceInput, rsiLengthInput))
rsi30m = request.security(syminfo.tickerid, "30", ta.rsi(rsiSourceInput, rsiLengthInput))
rsi1h = request.security(syminfo.tickerid, "60", ta.rsi(rsiSourceInput, rsiLengthInput))
rsi4h = request.security(syminfo.tickerid, "240", ta.rsi(rsiSourceInput, rsiLengthInput))
nm5uprsi = rsi5m>80 and rsi15m>70 and rsi30m>70 and rsi1h>70 and rsi4h>70
But the problem is, if timeframe is 5 minutes
rsi15m>70: need to have 3 candles m5>70 to be triggered
rsi30m>70: need to have 6 candles m5>70 to be triggered
rsi1h>70: need to have 12 candles m5>70 to be triggered
rsi4h>70: need to have 48 candles m5>70 to be triggered
What I need is: only the lastest m5 candle when rsi15m (or 30,1h,4h) >70 at that time
(It means:
rsi15m no need 2 previous candles m5 which have rsi>70
rsi30m no need 5 previous candles m5 which have rsi>70
rsi1h no need 11 previous candles m5 which have rsi>70
rsi4h no need 47 previous candles m5 which have rsi>70