Skip to main content

Against the Trend System for Amibroker (AFL)

fewy over 15 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 1)
  • Tags:
    trading system, amibroker

System to buy positions against the current trend.

Indicator / Formula

Copy & Paste Friendly
//Against the Trend System


_SECTION_BEGIN("Against the Trend System");
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 ) ) ));

z=(High+Low+(Close)*(2))/(4);
EMAavg=((34*EMA(z,2)+21*EMA(z,3))+(13*EMA(z,5))+(8*EMA(z,8))+(5*EMA(z,13))+(3*EMA(z,21))+(2*EMA(z,34)))/(87);
Plot(EMAavg,"EMAavg=",colorRed);



Buy =C>EMAavg AND C>EMA(C,5);
ex =C<EMAavg;



Buy = ExRem( Buy, ex );
ex = ExRem( ex, Buy ); 



Filter =  Buy;
/* Exploration Parameters */
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( C, "Close", 1.3 );


PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
//PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
//PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

_SECTION_END();

2 comments

almost 15 years ago

Wonder what’s the intention for putting this system here. A sure way to give money to Wall Street!

almost 15 years ago

hi sir

very good afl. Can anybody write sell signals to this afl.

Leave Comment

Please login here to leave a comment.