RSI Objective Lines
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar

//@version=5
indicator("RSI Objective Lines")

lookback      = input(defval = 200, title = 'Lookback')
threshold     = input(defval = 0.05, title = 'Threshold')

rsi_high = ta.rsi(high, 14)
rsi_low  = ta.rsi(low, 14)

// calculating the maximum range
max_range = ta.highest(rsi_high, lookback) - ta.lowest(rsi_low, lookback)

// support
support = ta.lowest(rsi_low, lookback) + (max_range * threshold)

// resistance
resistance = ta.highest(rsi_high, lookback) - (max_range * threshold)

plot(ta.rsi(close, 14))
plot(support,    color = ta.rsi(close, 14) > support?    color.green : na)
plot(resistance, color = ta.rsi(close, 14) < resistance? color.red : na)
