//想要达到的功能是,每天只能开仓一次,平仓则不限制,可以隔夜持仓
//测试发现0812这一天,还是开仓了2次。不知道哪里出问题了??
variable:buysign=1; {为1时可以开仓,为0时不可以}
if enterbars=1 then buysign:=0;
if buysign=1 AND holding=0 then
begin
if buycond then
begin
开多1:buy(1,1,limitr,buyprice);
end
else if buyshortcond then
begin
开空1:buyshort(1,1,limitr,buyshortprice);
end
end
if enterbars>=1 and holding<>0 then
begin
平多1:sell(holding>0 and sellcond,holding,limitr,sellprice);
平空1:sellshort(holding<0 and sellshortcond,holding,limitr,sellshortprice);
end
if closetime(0) then sellsgin:=1; {每天收盘时复原一次,以便下一天可以再开仓}