以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  交易次数代码无效,求点拨  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=68652)

--  作者:cssfortune
--  发布时间:2014/8/12 17:17:08
--  交易次数代码无效,求点拨

//想要达到的功能是,每天只能开仓一次,平仓则不限制,可以隔夜持仓

//测试发现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; {每天收盘时复原一次,以便下一天可以再开仓}


--  作者:jinzhe
--  发布时间:2014/8/12 17:24:23
--  
if enterbars=1 then buysign:=0;这句写在开仓语句后面
[此贴子已经被作者于2014/8/12 17:25:02编辑过]