// Downloaded From https://www.WiseStockTrader.com
//RSI(9) DIVERGENCE BUY:
Buy = RSI(9) >= HHV(RSI(9),-19) AND Close <HHV(Close,-19) OR Close <= LLV(Close,-19) AND RSI(9) > LLV(RSI(9),-19);

//RSI(9) DIVERGENCE SELL:
Sell = Close >= HHV(Close,-19) AND RSI(9)<HHV(RSI(9),-19) OR RSI(9) <= LLV(RSI(9),-19) AND Close > LLV(Close,-19);

Filter=(Buy OR Sell);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen);

PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);