-- 作者:FJ6008
-- 发布时间:2014/11/27 9:57:00
--
还是老问题:平多盈利执行不及时,盈利全部吃光:程序源码
//开多 IF ( stopprice)<l THEN BEGIN SELLSHORT( HOLDING<0,HOLDING,market); //平空操作 BUY( HOLDING=0,1,market);//开多操作 maxprofit:=0; END //平仓 SELL((stopprice)>h and HOLDING>0,HOLDING,market);//平多 BUYSHORT((stopprice)>h and HOLDING=0,1,market); //开空操作
if enterbars>=3 then begin if c>o and holding>0 then sell(1,holding,market); if c<o and type(1)= 2 then buy(holding>=0,1,market); end
//空头为例 if enterbars>=3 then begin if c>o and holding<0 then sellshort(1,holding,market); if c<o and type(1)=4 then buyshort(holding<=0,1,market); end
|
-- 作者:jinzhe
-- 发布时间:2014/11/27 10:06:45
--
那在这里一次性理清思路,你要的开仓后3根k线之外还是之内满足条件后平仓?
开仓后3根k线之外是原来的代码
开仓后3根k线之内是下面的代码
if enterbars<=3 then begin if c>o and holding>0 then sell(1,holding,market); if c<o and type(1)= 2 then buy(holding>=0,1,market); end
//空头为例 if enterbars<=3 then begin if c>o and holding<0 then sellshort(1,holding,market); if c<o and type(1)=4 then buyshort(holding<=0,1,market); end
|