大智慧三进三出交易系统公式
-
相关简介:大智慧三进三出交易系统公式 input:n1(20,10,99),n2(15,0,99),首仓(35,0,100),二仓(65,0,100),三仓(100,0,100),首止损(5,0,15) ,二止损(10,0,15),启用期(960101,901219,1500101),fl(5,0,30); st:=sma(h-l,20,1); u:ma(c,n1); d:ma(c,n2); pp:=avgenterprice; nb:=enterbars; ns:=exitbars; 测试期:=date
-
文章来源:股海网作者:股海网发布时间:2012-10-11浏览次数:
大智慧三进三出交易系统公式
input:n1(20,10,99),n2(15,0,99),首仓(35,0,100),二仓(65,0,100),三仓(100,0,100),首止损(5,0,15)
,二止损(10,0,15),启用期(960101,901219,1500101),fl(5,0,30);
st:=sma(h-l,20,1); u:ma(c,n1); d:ma(c,n2);
pp:=avgenterprice; nb:=enterbars; ns:=exitbars;
测试期:=date>启用期;
持仓:=holding;
券值:=持仓*c; {券值}
总资产:=券值+cash(0);
空仓历时:=barslast(持仓=0);
仓位:=券值/总资产*100; {仓位%}
浮利率:=c/pp*100-100; {持仓股获利率}
sv:=intpart(总资产/c/300+1)*100; {标准购买单位}
m:=cross(u,d);
p:=cross(d,u);
m1:=m and 测试期;
m2:=cross(c,ref(c,nb)*0.9) and 测试期; { and 持仓<sv*2}
m3:=cross(c,ref(c,nb)*(100+fl)/100) and 测试期; { and 持仓<sv*3}
mv1:=sv; {intpart((总资产*首仓-100*c*持仓)/c/10000)*100仓位控制到仓1}
mv2:=sv; {intpart((总资产*二仓-100*c*持仓)/c/10000)*100仓位控制到仓2}
mv3:=intpart(cash(0)/c/100)*100; {intpart((总资产*三仓-100*c*持仓)/c/10000)*100仓位控制到仓3}
f1:=cross(hhv(c,nb+1)*(100-首止损)/100,c);
f2:=cross(hhv(c,nb+1)*(100-二止损)/100,c);
p1:=f1*(sum(f1,nb)=1);
p2:=f2*(sum(f2,nb)=1);
p3:=p or cross(hhv(c,nb+1)*0.85,c);
pv1:=sv;
pv2:=sv;
pv3:=持仓;
开1:buy(m1,mv1,thisclose);
开2:buy(m2 and sum(p1+p2+p3,nb)=0,mv2,thisclose);
开3:buy(m3 and sum(p1+p2+p3,nb)=0 and m2=0,mv3,thisclose);
抛1:sell(p1,pv1,thisclose);
抛2:sell(p2,pv2,thisclose);
抛3:sell(p3,pv3,thisclose);