• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Tìm hiểu thêm.

Sử dụng Amibroker AFL for Moving Average trading with buy sell signal

traders

Administrator
Thành viên BQT
Tham gia ngày
29/4/17
Bài viết
224
Thích
3
Điểm
18
Website
traders.vn
#1
Sử dụng Amibroker AFL for Moving Average trading with buy sell signal










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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("MA_CROSS");
p = Optimize("PERIOD 1",Param("PERIOD 1",10,2,30,1),2,20,2);
q = Optimize("PERIOD 2",Param("PERIOD 2",90,10,200,10),10,100,10);
y = Optimize("MAType 1",Param("MAType 1",2,1,8,1),1,8,1);
z = Optimize("MAType 2",Param("MAType 2",2,1,8,1),1,8,1);

m=0; if (y==1) m = MA(C,p);
else if (y==2) m = EMA(C,p);
else if (y==3) m = DEMA(C,p);
else if (y==4) m = TEMA(C,p);
else if (y==5) m = WMA(C,p);
else if (y==6) m = HMA(C,p);
else if (y==7) m = Wilders(C,p);
else if (y==8) m = LinearReg(C,p);

n=0; if (z==1) n = MA(C,q);
else if (z==2) n = EMA(C,q);
else if (z==3) n = DEMA(C,q);
else if (z==4) n = TEMA(C,q);
else if (z==5) n = WMA(C,q);
else if (z==6) n = HMA(C,q);
else if (z==7) n = Wilders(C,q);
else if (z==8) n = LinearReg(C,q);
Plot(m," MA",IIf(m < Ref(m,-1),colorBlue,colorRed),styleThick);
Plot(n," MA",IIf(n < Ref(n,-1),colorBlue,colorRed),styleThick);

Buy = Cross(m,n);
Sell = Cross(n,m);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = Sell; Cover = Buy;
PlotShapes(Buy+2*Sell,colorWhite,0,IIf(Buy,L,H));
SetPositionSize(1,4);
_SECTION_END();
 
Top