// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("Williams  %R with 9 period signal line");
/* Williams %R and 9 day Mov.avg.*/
/* by Anthony Faragasso */
MaxGraph =10;

tr=Param("tr",9,1,60,1);

R = ((HHV(H,tr) - C) /(HHV (H,tr) -LLV (L,tr))) *-100;
Graph0 = R;
Graph1 =-30;
Graph2 =-70;
Graph3 =-90;
Graph4 =-10;
Graph5=MA(R , 9);
Graph5Style = 1+4;
Graph5Color =1;
Graph0Style=1+4;
Graph1Style =Graph2Style= 1;
Graph3Style  =Graph4Style =2;
Graph3Color = Graph4Color =5;
Graph2Color = Graph1Color =12;




 Plot(-40,"",colorBlack,styleLine);
Buy= R>-30 ;
Sell= R<-40 ;
Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); 
PlotShapes( shapeUpArrow*Buy  , colorGreen ,0);
PlotShapes( shapeDownArrow*Sell , colorRed ,0);
/*x = BarsSince( Cross( r, MA( r, 9)));*/
/*y = BarsSince( Cross( MA(r, 9), r));*/
/*Graph8 = ( x == 0 OR y == 0 ) * 30;*/

Title =Name() + " -Williams %R: " +" % R Line " +"("+ WriteVal ( Graph0,format=1.2)+")"+ "  Signal Line " + ""+"("+WriteVal(Graph5,format=1.2)+")" +" , "   + Date(  );
_SECTION_END();