EMA Trade code



_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();
_SECTION_BEGIN("EMA");
Range1=Optimize("range1",14,1,20,1);
Range2=Optimize("range2",206,1,125,1);
Buy = Cross((EMA(Close,range1)),(EMA(Close,range2)));
Sell = Cross(EMA(Close,range2),(EMA(Close,range1)));
Short = Sell;
Cover = Buy;
// plot expanded average
Plot(EMA( Close,range1), "70min-ema", colorRed );
Plot(EMA( Close,range2), "1030min-ema", colorGreen );
// plot arrows
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
_SECTION_END();

0 nhận xét: