想在15:14:00下单平仓,但尾盘平仓的时间老是与想要的不符,写过两种代码,都不符,请老师指点,现策略代码如下:
第一种:
平仓时间:=TIME>=CLOSETIME(0)-1*100;
收平多:sell(平仓时间 and holding>0, 0, thisclose);
收平空:sellshort(平仓时间 and holding<0,0,thisclose);
第二种:
收平多:sell(time>151359 and holding>0, 0, thisclose);
收平空:sellshort(time>151359 and holding<0,0,thisclose);
实盘时,用“固定时间间隔1秒”的轮询模式,一到尾盘,两种写法都在15:13:00就下单平仓了,我是想在15:14:00下单平仓的,应该怎么写代码,图表交易时用什么模式?
用固定时间间隔轮询模式,对吧?
如果要求在15:13:50之后平仓,应该怎么编写代码?
这个需要用currettime来判断
不过图表上得要这么写
if (islastbar and currettime>151350 ) or (not(islastbar) and time=151400)
编写不进去,是不是这样?
平仓时间:= (islastbar and currettime>151350 ) or (not(islastbar) and time=151400);
收平多:sell(平仓时间 and holding>0, 0, thisclose);
收平空:sellshort(平仓时间 and holding<0,0,thisclose);
我写if是if ....then begin 的if,不是if(cond,a,b)的if