// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();


a1=L>Ref(L,-1) AND H<Ref(H,-1);
a2=H-L;
a3=Ref(HHV(H,20),-1)>Ref(HHV(H,20),-2);
a4=Ref(HHV(H,20),-5)<Ref(HHV(H,20),-4) AND Ref(HHV(H,20),-5)<Ref(HHV(H,20),-3) AND Ref(HHV(H,20),-5)<Ref(HHV(H,20),-2);
a5=a2>Ref(a2,-1) AND a2>Ref(a2,-2) AND a2>Ref(a2,-1) AND Open<Ref(HHV(H,20),-1);

Buy = C< Ref(LLV(C,500),-1);
 
//Condition for sell : Exit when LLV500 IS EXCEEDED.
Sell = a5 AND a3 AND a4;;
 
Buy = ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);
 
Short = Sell;
Cover = Buy;
 
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

shape = Buy * shapeUpTriangle + Sell * shapeDownTriangle;
PlotShapes( shape, IIf( Buy, colorGreen, colorBrown ),0, IIf( Buy, Low, High ) );

_SECTION_BEGIN("DispWMA");
P = ParamField("Field");
Type = ParamList("Type", "Weighted,Simple,Exponential,Double Exponential,Tripple Exponential,Wilders");

Periods16 = Param("Periods16", 100, 2, 300 );
Periods32 = Param("Periods16", 200, 2, 300 ); 
Displacement3 = Param("Displacement3", 6, -50, 50 );
Plot( WMA( P, Periods16 ), _DEFAULT_NAME(), colorBlue, styleStaircase, 0, 0, Displacement3  );
Plot( WMA( P, Periods32 ), _DEFAULT_NAME(), colorRed, styleStaircase, 0, 0, Displacement3  );