以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]出场规则代码编写  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=80118)

--  作者:ZCLam
--  发布时间:2015/6/25 11:19:56
--  [求助]出场规则代码编写
请问老师,下面这6个出场规则用代码该如何来表述啊?

1,目标周期:在开仓9个周期后,无条件平仓。

2,目标利润:与开仓价i相比,利润率达到0.8%时,平仓。

3,最大损失:与开仓价相比,损失率达到0.03%时,平仓。

4,回落平仓:与最高时间相比5个周期价格不利变动达0.03%时,平仓。

5,横盘平仓:与开仓价相比5个周期内有利幅度小于0.03%时,平仓。

6,回吐止盈:与开仓价相比利润率0.7%后回吐30%时,止盈。

--  作者:jinzhe
--  发布时间:2015/6/25 11:27:39
--  

1.if enterbars>9 then begin

     sell(1,0,market);

     sellshort(1,0,market);

   end

 

2.if holding>0 and (c-enterprice)/enterprice>0.008 then sell(1,0,market);

   if holding<0 and (enterprice-c)/c>0.008 then sellshort(1,0,market);

 

3. if holding>0 and (enterprice-c)/c>0.003 then sell(1,0,market);

    if holding<0 and (c-enterprice)/enterprice>0.003 then sellshort(1,0,market);

 

4,5,6不能公布算法