Skip to main content

TEMA_Regression Crossover for Amibroker (AFL)

marcheur almost 13 years ago Amibroker (AFL)

  • Rating:
    2 / 5 (Votes 4)
  • Tags:
    amibroker, exploration

This is a crossover trading system with Buy signals when 50 p TEMA crosses above 100 p Regression and Sell signal when TEMA crosses below Regression. It can be used for exploration and back testing.

Indicator / Formula

Copy & Paste Friendly
_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", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("Linear Regression");
P1 = ParamField("Price field",-1);
Periods1 = Param("Periods", 100, 2, 300, 1, 10 );
Plot( LinearReg( P1, Periods1 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();

_SECTION_BEGIN("MA");
P2 = ParamField("Price field",-1);
Periods2 = Param("Periods", 50, 2, 300, 1, 10 );
Plot( TEMA( P2, Periods2 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();

Buy= Cross(TEMA( P2, Periods2 ), LinearReg( P1, Periods1 ));
Sell=Cross(LinearReg( P1, Periods1 ), TEMA( P2, Periods2 ) );

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Filter=Buy OR Sell; 

AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange); 

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );

0 comments

Leave Comment

Please login here to leave a comment.