I've adapted for PINE v4
Good luck to all the Padawans!
//@version=4
//RSI with overbought and oversold alert area
study(title="RSI w/ Overbought & Oversold Alert", shorttitle="RSI", precision=1)
//declare RSI
src = input(close, title="RSI Source")
len0 = input(14, minval=1, title="Length")
up = rma(max(change(src), 0), len0)
down = rma(-min(change(src), 0), len0)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//RSI Plot with over sold (Green) and over bought (Red)
//Over SOLD Color (buy indicator)
clrS = #2196f3
//Over BOUGHT Color (sell indicator)
clrB = #FF0000
//RSI peaks
clr = #00000064
if rsi >= 70
clr := clrB
if rsi <= 30
clr := clrS
Good luck to all the Padawans!
//@version=4
//RSI with overbought and oversold alert area
study(title="RSI w/ Overbought & Oversold Alert", shorttitle="RSI", precision=1)
//declare RSI
src = input(close, title="RSI Source")
len0 = input(14, minval=1, title="Length")
up = rma(max(change(src), 0), len0)
down = rma(-min(change(src), 0), len0)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//RSI Plot with over sold (Green) and over bought (Red)
//Over SOLD Color (buy indicator)
clrS = #2196f3
//Over BOUGHT Color (sell indicator)
clrB = #FF0000
//RSI peaks
clr = #00000064
if rsi >= 70
clr := clrB
if rsi <= 30
clr := clrS
//Feature
plot(rsi, color=color.white, title="RSI")
plot(rsi, color=clr, linewidth=4, title="RSI Peak Overlay")
//Thresholds
band1 = hline(70, color=#FF000050, linestyle=hline.style_dotted, linewidth=1, title="RSI Upper Limit")
band0 = hline(30, color=#2196f350, linestyle=hline.style_dotted, linewidth=1, title="RSI Lower Limit")
//Background fill
fill(band1, band0, color=#4985E7, transp=95, title="RSI Hlines Background")
//end