我是新手,学习策略,在期指5分钟线上,每天开盘的时候,判断上一日3点15分的收盘与3点的收盘相比是涨还是跌,若涨就开多,若跌就开空,然后在当日15时平仓。
我写出来了,系统总是不执行,哪位高人都告诉,问题出在哪里了,谢谢。
p1:=ref(c,1);//3点15的价格
p2:=ref(c,4);//3点的价格
sell(time=150000 and holding>0 ,0,limitr,thisclose);//平多
sellshort(time=150000 and holding<0 ,0,limitr,thisclose);//平空
buyshort(p1<p2 and day<>ref(day,1) and holding=0 ,1,limitr,open);//开空
buy(P1>p2 and day<>ref(day,1) and holding=0 ,1,limitr,open);//开多
你应该用这个函数
引用自 1900 年以来指定日期的数据.
用法: REFDATE(X,DATE[,TIME]),引用 DATE 日期 TIME (可省略)的 X 值.
例如:REFDATE(CLOSE,1011208)表示 2001 年 12 月 08 日的收盘价;
REFDATE(CLOSE,1011208, 133030)表示 2001 年 12 月 08 日 13:30:30 的收盘价
TIME参数可省略使用,省略时间一般用在日线及其以上周期使用,对于日线以下周期则一般需要带时间参数。
注意:对于逐K线运行模式,X值不可以引用到未来数据,但是序列模式则无此限。
所属函数组:引用函数
p1:=ref(c,1);//3点15的价格
p2:=ref(c,4);//3点的价格
k1:=time=150000 and holding>0;
if k1 then
begin
sell(k1,0,limitr,c);//平多
end
k2:=time=150000 and holding<0;
if k2 then
begin
sellshort(k2,0,limitr,c);//平空
end
k3:=p1<p2 and day<>ref(day,1) and holding=0;
if k3 then
begin
buyshort(k3,1,limitr,o);//开空
end
k4:=(P1>p2 and day<>ref(day,1) and holding=0);
if k4 then
begin
buy(k4,1,limitr,o);//开多
end
这样试试