I would like to code the RSI Failure Swings. Things I need for the calculation:
- A new closing high/low with overbought/sold conditions - Done
- After that a higher/lower close with normal RSI conditions (divergence) - Done
- Take the lowest/highest RSI reading between those new closing highs/lows - Problem
- When RSI crosses the RSI reading mentioned at point 3, give feedback of completed failure swing - Quasi-done
I already managed to give a heads up when the divergence happens, so point 1 and 2 are fine. But how do a get the lowest/highest RSI reading between those bars?
I tried something like this for a Top Failure Swing (AKA Bearish Failure Swing):
lowestrsi = valuewhen(bearishdivergence, lowest(rsi, barssince(overbought)), 0)
My thinking was: find the bar with bearish divergence and return the lowest RSI reading between that bar and the bar prior to that with a overbought condition.
But that doesn't work because the second argument of lowest() can't be a series! If you replace that argument with a number, let's say 10, it works perfectly and I get notified of a failure swing. But the problem is, is that there's no default value for something like this. Meaning you can't hardcode something like '10' or some other number.
Question: How do I get the lowest RSI between the bars mentioned at point 1 and 2? Or how do I turn a series into an integer? Is that even possible? Or is it possible to get a single integer from a series?