TradingView
Trendoscope
Oct 2, 2021 3:38 AM

RSI - Dynamic Overbought/Oversold Range 

SPDR S&P 500 ETF TRUSTArca

Description

Default overbought/oversold levels of RSI does not hold good for instruments which are trending well. It happens often that instruments keep trading in single half of the range for prolonged time without even touching the other half. This also came up often in tradingview pine chat discussions where I participate regularly.

Hence, thought of creating this script to help other scriptors in finding different methods to derive dynamic high/low range of RSI. This can also be adopted for other range bound oscillators - though not inlcuded in this script.

⬜ Method

▶ Derive multitimeframe RSI. Parameters - Resolution, Source and Length are pretty straight forward. Repaint when unchecked uses previous bar value.
▶ Dynamic range detection follows below steps.
  • Get highest and lowest of the oscillator source for Range Length period.
  • Use Detection method further to refine the highest and lowest range. If detection method is "highlow", then it looks for lowest value for high range and highest value for low range. If not, uses moving average.


◽Note: Detection range length is used only for finding highest and lowest of Oscillator value ranges. Further detection range method of highlow and other moving average types use Oscillator length.

Release Notes

Minor correction - removed few redundant lines.

Release Notes

Added sticky range option to stick levels till crossover. Converted script to pine 5 :)
Comments
mofa3800
👍👏
Trendoscope
@mofa3800, thanks for your support :)
Muxxy17
Great job, thanks for this. Added a few edits such as an EMA of the RSI and a mid line of the range. Works very well.
NAK1987
Great work as always .. This is a really good idea for mean reversion trading I think . Still loving your zz supertrend for a LABD/LABU strategy that I'm working on in the mornings for the first hour ... its profitable so far ;)
Trendoscope
@NAK1987, thanks mate :)
hsnkty
thanks
uhsirait
Great work sir, love your works as always. Looking forward if you have plan to add divergences in this RSI.
ShadowKillerFx
It is good, may you add Lebel to the RSI, it can make more confidence.
Thanks,
rafaelcoisaa
hey, master of the zigzags
i try that function below in your scripts:

f_highestbars(_len) =>
_index = 0
_highest = 0.0
for _i = 0 to _len-1
if high[_i]>_highest //here
_highest := high[_i]
_index := _i
-_index

f_lowestbars(_len) =>
_index = 0
_lowest = 10e20
for _i = 0 to _len-1 //here
if low[_i]<_lowest
_lowest := low[_i]
_index := _i
-_index

it's the tradingview function without the equal sign here 'if high[_i]>_highest' and here 'if low[_i]<_lowest'.
good results, the line is not updated in double tops and double bottoms.
thanks man.
More