而对于以k线结束价发单的交易方法,我现在的滑点基本上可以控制在-0.03-0.05点之间,也就是说交易一次的滑点成本在15元以内。可能很多人的策略如果按这个成本设置,其收益曲线就很漂亮。
//调用hdkzh程序中的5个参数
xdd:=stkindiex('','hdkzh.xdtd',0,21,1,0);//21,1 你使用的周期;
xdk:=stkindiex('','hdkzh.xdtk',0,21,1,0);//k线数量根据自己的模型确定;
hd1:=stkindiex('','hdkzh.hd1',0,21,1,0);
hdk:=stkindiex('','hdkzh.hdk',0,21,1,0);
hdd:=stkindiex('','hdkzh.hdd',0,21,1,0);
jgs:=if(islastbar,dynainfo(21),c);
jgx:=if(islastbar,dynainfo(20),c);
//交易时间区间
p1:=time>091700 and time<=150000;
p2:=if(islastbar,dynainfo(207),time);
p3:=time0-timetot0(p2),linethick0;
//以上部分要在程序加入。
r1:=todaybar-1;
r5:=ma(c,10);
r6:=ma(c,20);
if cross(r5,r6) and p3<=min(xdd,7) and p1 then
begin
sellshort(holding<0,abs(holding),limitr,jgx+hd1+hdd);
buy(holding=0,1,limitr,jgx+hd1+hdd);
end
if cross(r6,r5) and p3<=min(xdk,7) and p1 then
begin
sell(holding>0,holding,limitr,jgs-hd1-hdk);
buyshort(holding=0,1,limitr,jgs-hd1-hdk);
end
//收盘前清仓
if (p2>=151000 or (date=1140117 and time>145700)) and holding>0 and p3<=xdk then
begin
js5:sell(holding>0,holding,limitr,jgs-hd1-hdk);
end
if (p2>=151000 or (date=1140117 and time>145700)) and holding<0 and p3<=xdd then
begin
js6:sellshort(holding<0,abs(holding),limitr,jgx+hd1+hdd);
end
//**************************
日盈亏:asset-ref(asset,r1+1),noaxis,colorred,linethick1;
//1.追单:4秒不成交,在30个范围内市价追单;
//2.程序不能使用未来函数或者数据,否则可能频繁交易;
//3.使用固定轮询,高频;
//4.持仓同步时间,设置为10秒。如果是单窗口运行,持仓同步设为“走完k线以后”;
//5.程序中不允许使用"orderqueue"指令;
这个东西说简单也简单,但是你要花很多时间去统计,和实盘测试,有时可能还要浪费不少人民币。所以程序模块"hdkzh",不会免费提供,我做了一个2014年8月30号到期的加密“hdkzh”,大家可以自由使用。