_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", colorDefault, styleNoTitle | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods1 = Param("Periods1", 9, 1, 500, 1, 10 );
Periods2 = Param("Periods2", 30, 1, 500, 1, 10 );
Plot(e9 = EMA( P, Periods1 ), StrFormat(_SECTION_NAME()+"(%g)", Periods1), ParamColor( "Color1", colorRed ), ParamStyle("Style") );
Plot(e30 = EMA( P, Periods2 ), StrFormat(_SECTION_NAME()+"(%g)", Periods2), ParamColor( "Color2", colorBlue ), ParamStyle("Style") );
Buy = Cross(e9, e30);
Sell = C < e30 AND Ref(C,-1) < Ref(e30,-1) AND Ref(C,-2) < Ref(e30,-2);
Buy = ExRem(Buy,Sell); Sell = ExRem(Sell,Buy);
Short = e9 < e30;
Cover = C > e30 AND Ref(C,-1) > Ref(e30,-1) AND Ref(C,-2) > Ref(e30,-2);
Short = ExRem(Short,Cover); Cover = ExRem(Cover,Short);
PlotShapes(Buy+2*Short, colorWhite, 0,IIf(Buy,L,H));
PlotShapes(3*Cover+4*Sell, colorWhite, 0,IIf(Cover,L,H),-24);
Color1 = IIf( EMA(p,periods1) > EMA(p,periods2), colorGreen, colorYellow);
Plot(1, "", Color1, styleArea | styleOwnScale | styleNoLabel, -0.1, 30 );
_SECTION_END();