以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请教减仓的问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=59752)

--  作者:punkcat401
--  发布时间:2013/12/10 9:53:55
--  请教减仓的问题

多头三次加仓,第一次加仓1手,第二次加仓2手,第三次加仓3手

 

3次加仓后,跌破最近第三次加仓价格的50点后,只平掉第三次加仓的3手。

 

跌破第二次加仓价格的50点后,只平掉第二次加仓的2手。

[此贴子已经被作者于2013/12/10 9:54:14编辑过]

--  作者:jinzhe
--  发布时间:2013/12/10 10:02:08
--  

交易是没有特定的哪个3手,哪个2手的,只有平3手,平2手

 

variable:k=0;

variable:e1=0;

variable:e2=0;

 

 

if k=0 and 开仓条件 and holding=0 then begin

    buy;

    k:=1;

end

 

if k=1 and 加仓条件 and holding=1 then begin

     buy(1,1,market);

     k:=2;

end

 

if k=2 and 加仓条件 and holding=2 then begin

     buy(1,2,market);

     e1:=enterprice;

     k:=3;

end

 

if k=3 and 加仓条件 and holding=3 then begin

      buy(1,3,market);

      e2:=enterprice;

      k:=4;

end

 

if e1-c>50*mindiff then sell(1,2,market);

 

if e2-c>50*mindiff  then sell(1,3,market);