//股指期货自动交易程序(7分钟日内OBV交易系统)
//编制:
//日期:
{
//加密及期限
drawtextex(1,1,200,800,engincode());
rzb:=strcmp(engincode(),'aaaaaaaaaa');
if rzb<>0 then
begin
drawtextex(1,1,500,500,'程序不能在此计算机上运行');
exit;
end
有效期:1121230,linethick0;
账号:11111,linethick0;
zhh:=strtonum(taccount(1));
if zhh<>账号 then
begin
drawtextex(1,1,500,500,'授权账号不正确,程序无法使用');
exit;
end
if date>有效期 then
begin
drawtextex(1,1,500,500,'已过授权时间,程序无法使用');
exit;
end
if datatype<>17 then
begin
drawtextex(1,1,50,950,'本程序使用3分钟周期,请切换到3分钟周期');
exit;
end
}
//========================================================
//交易控制变量
//**********************************
//交易手数:
tn:=1;
//最大持仓量
cx:=1;
//提前下单量(秒)
xd:=3;
//交易时间区间
p1:=time>091800 and time<150000;
p2:=if(islastbar,dynainfo(207),time);
p3:=time0-timetot0(p2),linethick0;
//********************************
r1:=barslast(date<>ref(date,1));
r2:=ref(o,r1+1);
//********************************
hd:=if(islastbar,3,1);//即时下单加1点的滑点;
hd1:=if(islastbar,3,0.2);//k线走完提前3秒下单加0.2点的滑点;
//********************************
robv:=sum(if(close>ref(close,1),vol,if(close<ref(close,1),-vol,0)),0);
//********************************
rh:=ref(hhv(robv,n1),1);
rl:=ref(llv(robv,n1),1);
//********************************
if robv>rh and p1 then
begin
sellshort(holding<0,0,thisclose);
buy(holding=0,tn,thisclose);
end
if robv<rl and p1 then
begin
sell(holding<0,0,thisclose);
buyshort(holding=0,tn,thisclose);
end
//***************************
if holding>0 and c<enterprice-3 and p1 then
begin
buy(holding<cx,tn,thisclose);
end
if holding<0 and c>enterprice+3 and p1 then
begin
buyshort(abs(holding)<cx,tn,thisclose);
end
//收盘前清仓
if p2>=151200 then
begin
sellshort(holding<0,0,limitr,c+hd1);
sell(holding>0,0,limitr,c-hd1);
end
//*************************************
交易总数:totaltrade,colorwhite,linethick0;
盈亏:asset-1000000,colorred,linethick1,noaxis;
日盈亏:asset-ref(asset,r1+1),noaxis,colorred,linethick0;
持仓:holding,colorwhite,linethick0;