# RSIPullBack
# Converted from Pinescript to ThinkScript by rad14733 on 2023-08-07
# Original source: https://www.tradingview.com/script/8MncpUj9-RSI-Pull-Back/
input lookback = 14;
input lower_barrier = 30;
input lower_threshold = 40;
input upper_barrier = 70;
input upper_threshold = 60;
def rsi = reference RSI(length = lookback);
def buy_signal = rsi >= lower_barrier and rsi < rsi[1] and rsi[1] > lower_barrier and rsi[1] < lower_threshold and rsi[2] < lower_barrier;
def sell_signal = rsi <= upper_barrier and rsi > rsi[1] and rsi[1] < upper_barrier and rsi[1] > upper_threshold and rsi[2] > upper_barrier;
plot buy = if buy_signal then low else Double.NaN;
buy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buy.SetDefaultColor(Color.ORANGE);
buy.SetLineWeight(5);
plot sell = if sell_signal then high else Double.NaN;
sell.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sell.SetDefaultColor(Color.ORANGE);
sell.SetLineWeight(5);
# END - RSIPullBack