次周期收盘价?refx(c,1)
但是是未来
给你一个模板,这是我一直使用的
//股指期货自动交易程序(长线交易系统5号系统)(30分钟持仓过夜)
//编制:
//日期:2012年12月8日 定稿
{
//加密及期限
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<>4 then
begin
drawtextex(1,1,500,500,'本程序使用30分钟周期,请切换到30分钟周期');
exit;
end
//========================================================
//交易控制变量
variable:a1=1;
variable:a2=0;
variable:c1=1;
variable:c2=1;
variable:c3=1;
variable:c4=1;
//**********************************
//交易手数:
tn:=1;
//最大持仓量
cx:=3;
//提前下单量(秒)
xd1:=3;
//滞后下单量(秒)
xd1:=3;
//交易时间区间
p1:=time>=091500 and time<=150000;
p2:=if(islastbar,dynainfo(207),time);
p3:=time0-timetot0(p2),linethick0;
//*************************************
r1:=barslast(date<>ref(date,1));
r2:=ref(o,r1);
//*******************************
hd:=if(islastbar,5,0.6);//k线中交易
hd1:=if(islastbar,5,0.2);//k线走完交易
//*******************************
//*******************************
//收盘前清仓
if p2>=150955 then
begin
sellshort(holding<0,0,limitr,c-hd1);
sell(holding>0,0,limitr,c+hd1);
end
//*************************************
交易总数:totaltrade,colorwhite,linethick0;
盈亏:asset-2000000,colorred,linethick1,noaxis;
日盈亏:asset-ref(asset,r1+1),noaxis,colorred,linethick0;
持仓:holding,colorwhite,linethick0;
rr1:=barslast(month<>ref(month,1));
月盈利:asset-ref(asset,rr1+1),linethick0;
如果提前xd1秒下单,你的条件是 A
if a and p3<=xd1 then.................
如果是滞后下单
if ref(a,1) and p3>180-xd2{假如是3分钟周期} then......
如果是次周期收盘价交易,提前xd1秒下单。
if ref(a,1) and p3<=xd1 then。。。。。。。
滞后下单这么写:
if ref(a,1) and p3<180-xd2 and p3>180-xd2-2 then {假定是3分钟周期,滞后3-5秒下单}
//收盘前清仓
if p2>=150955 then
begin
sellshort(holding<0,0,limitr,c+hd1);
sell(holding>0,0,limitr,c-hd1);
end
//滞后下单量(秒)
xd2:=3;
不好意思,有点错误。
隔一周期下单 很简单的
将下单条件由本周期达成 改为 上周期达成
想隔多少周期都成 改为前N周期条件达成
不需要蛋疼的函数
那样的话和你的条件就有很多关系,在一个大系统里显然没有你自己写的效率高。这个一点都不麻烦啊。