I am running into the following issue with my code: ** Warning at 259:21 The function 'ta.rsi' should be called on each calculation for consistency. It is recommended to extract the call from this scope**
I want to see if RSI dipped below 40 at any point while a pullback was happening. I don't see how I could check this without performing an RSI calculation with a for loop. I already have the start and stop bars of the pullback and whether it was a positive or negative pullback. Any help would be much appreciated, thank you!
getRSIStatus(startBar, endBar, pullbackType) =>
status = "neutral"
var float rsiValue = na
for i = startBar to endBar
rsiValue := ta.rsi(close[i], 14)
isPositivePullback = pullbackType == "up"
if (isPositivePullback and rsiValue > 60)
status := "overbought"
break
else if (not isPositivePullback and rsiValue < 40)
status := "oversold"
break
status```
Moving RSI fetch part to another method will resolve this issue.