// Downloaded From https://www.WiseStockTrader.com
/* Relative Momentum Index */
/* AFL code by Prakash Shenoi */

Length=Param("Length?",2,3,20,1);//default =14 or 20
mom=Param("Momentum?",2,3,11,1);//default = 4 or 5
xRMI = RMI(Length,mom);
Plot(xRMI, " Relative Momentum Index ("+WriteVal(Length,1.0)+")", 34+4,1 + styleThick);
Plot(70,"",colorDarkGrey,styleDashed|styleNoLabel);//OS
Plot(30,"",colorDarkGrey,styleDashed|styleNoLabel);//OB
Buy = Cross( xRMI, 30 );
Sell = Cross( 70, xRMI );
PlotShapes( shapeUpArrow * Buy + shapeDownArrow * Sell, IIf( Buy, colorGreen, colorRed ) );
GraphXSpace=5;
/*Buy and Sell Conditions*/
Buy  = Ref(xRMI,-1)<40 AND xRMI > Ref(xRMI,-1);
Sell = Ref(xRMI,-1)>70 AND xRMI < Ref(xRMI,-1);

Buy  = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
/*End Buy and Sell Conditions*/