Skip to content

Instantly share code, notes, and snippets.

@marketcalls
Created November 9, 2014 18:20
Show Gist options
  • Save marketcalls/afb787eaccae0086b084 to your computer and use it in GitHub Desktop.
Save marketcalls/afb787eaccae0086b084 to your computer and use it in GitHub Desktop.
Simple Moving Average Crossover
_SECTION_BEGIN("");
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("MA5-MA20 Crossover");
Buy = Cross( MA( Close, 5 ), MA( Close, 20 ) );
Sell = Cross( MA( Close, 20 ), MA( Close, 5 ) );
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-15);
PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-15);
_SECTION_END();
Plot( MA( Close,5 ),"MA5",colorRed,styleLine);
Plot( MA( Close,20),"MA20",colorBlue,styleLine);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment