RSI Pull-Back
// 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 Pull-Back", overlay = true)

lookback = input(defval = 14, title = 'Lookback')

lower_barrier = input(defval = 30, title = 'Lower Barrier')
lower_threshold = input(defval = 40, title = 'Lower Threshold')

upper_barrier = input(defval = 70, title = 'Upper Barrier')
upper_threshold = input(defval = 60, title = 'Upper Threshold')

rsi = ta.rsi(close, lookback)

buy_signal  = rsi >= lower_barrier and rsi < rsi[1] and rsi[1] > lower_barrier and rsi[1] < lower_threshold and rsi[2] < lower_barrier
sell_signal = rsi <= upper_barrier and rsi > rsi[1] and rsi[1] < upper_barrier and rsi[1] > upper_threshold and rsi[2] > upper_barrier

plotshape(buy_signal,   style = shape.triangleup, color   = color.blue, location =  location.belowbar, size = size.small)
plotshape(sell_signal,  style = shape.triangledown, color = color.orange, location   =  location.abovebar, size = size.small)
