{1、计算N1个周期内收盘价的加权平均值D1
计算N1个周期内阳线收盘价的加权平均P1与N1个周期内阴线收盘价的加权平均P2
通过计算得出一个M1=D1*|S1/S2|
2、计算N2个周期内收盘价的加权平均值D2
计算N2个周期内阳线收盘价的加权平均P3与N个周期内阴线收盘价的加权平均P4
通过计算得出一个M2=D2*|P3/P4|
3、当M1上穿M2,做多
当M1下穿M2,做空 }
input:n1(5),n2(10);
d1:=wma(c,n1);
cc:=if(isup,c,0);
dd:=if(isdown,c,0);
p1:=wma(cc,n1);
p2:=wma(dd,n1);
m1:=d1*(p1/p2);
d2:=wma(c,n2);
p3:=wma(cc,n2);
p4:=wma(dd,n2);
m2:=d2*(p3/p4);
if cross(m1,m2) then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if cross(m2,m1) then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
r:=10;
if barslast(cross(m1,m2))<=r then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if barslast(cross(m2,m1))<=r then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
n:=20
xx:=if(isup,c,0);
yy:=if(isdown,c,0);
w1:=sum(xx,n)*sum(xx,n);
w2:=sum(yy,n)*sum(yy,n);
p1:=w1*(w1/w2);
p2:=w2*(w2/w1);
if cross(p2,p1) then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
if cross(p1,p2) then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end