input:grid(3,1,60,1);
variable:level=0;
dist:=barslast(date<>ref(date,1));
oo:=ref(open,dist);
if holding=0 then begin
dnprice:=oo-grid*mindiff;
if low<=dnprice then begin
buy(1,1,limitr,dnprice);
level:=-1;
end
end
if holding=0 then begin
upprice:=oo+grid*mindiff;
if high>=upprice then begin
buyshort(1,1,limitr,upprice);
level:=1;
end
end
if holding>0 then begin
upprice:=oo+(level+1)*grid*mindiff;
dnprice:=oo+(level-1)*grid*mindiff;
if high>=upprice then begin
sell(1,1,limitr,upprice);
level:=level+1;
end
if low<=dnprice then begin
buy(1,1,limitr,dnprice);
level:=level-1;
end
if time=closetime(0) then
sell(1,holding,limitr,close);
end
if holding<0 then begin
upprice:=oo+(level+1)*grid*mindiff;
dnprice:=oo+(level-1)*grid*mindiff;
if low<=dnprice then begin
sellshort(1,1,limitr,dnprice);
level:=level-1;
end
if high>=upprice then begin
buyshort(1,1,limitr,upprice);
level:=level+1;
end
if time=closetime(0) then
sellshort(1,holding,limitr,close);
end
盈亏:asset,noaxis,colormagenta;
收益:(asset-50000)/50000,linethick0;
次数:totaltrade,linethick0;
胜率:percentwin,linethick0;
连亏:maxseqloss,linethick0;
连赢:maxseqwin,linethick0;
要实盘使用的话,可以单独联系我再调整。
我自己建立了一个网站,专门进行程序化交易研究,提供免费的策略分享,欢迎访问,共同研究学习:
疯狂宽客:http://www.crazyquants.com
疯狂宽客论坛:http://bbs.crazyquants.com/forum.php