// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("RSI DYNAMIC");
i=0;
Period = Param("Period", 12, 2, 30, 1);
myRSI = RSI(Period);
Adev = StDev(myRSI, 3*Period);
Hiline = 50 + 2.2*Adev;
Loline = 40 - 1.6*Adev;
Plot(myRSI,"",colorBlue,8);
Plot(Hiline,"",colorRed,4);
Plot(Loline,"",colorGreen,4);
Title = " " +Name() +
" Dynamic RSI Threshold, t = " + 
WriteVal(period, format=1.0) + " "; 

Buy = (RSI(12)<= Loline);
Sell = (RSI(12)>= Hiline);
PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);

R1=RSI(12)<= Loline ;
R2=RSI(12)>= Hiline ;
IIf(R1,i+1,i);
RSIStatus=WriteIf(R1,"Bullish",WriteIf(R2,"Bearish",WriteIf(IsNull(RSI(12)),"N/A","Neutral")));
RSIColor=IIf(R1,colorGreen,IIf(R2,colorRed,colorLightGrey));


 
Filter = 1;

AddTextColumn(RSIStatus,"RSI DYNAMIC",1,colorWhite,RSIColor);


_SECTION_END();