以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  老师,帮写一下这策略  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=97082)

--  作者:AK之王
--  发布时间:2016/5/5 16:15:24
--  老师,帮写一下这策略
如果条件1成立则买入1手,亏三个波动单位止损,条件2成立平仓,平仓后价格往上波动5个单位后再次买入(追涨),追涨部分亏5个波动单位止损,追涨部分条件3成立平仓。
--  作者:jinzhe
--  发布时间:2016/5/5 16:56:03
--  

variable:bj=0;

if cond1and bj=0 and holding=0 then begin

     buy(holding=0,1,marketr);

     bj:=1;

end

if c<enterprice-3*mindiff and holding>0 and bj=1 then sell(1,0,marketr);

if cond2 and holding>0 and bj=1 then sell(1,0,marketr);

if holding=0 and c>exitprice+5*mindiff and bj=1 then begin

     buy(1,1,marketr);

     bj:=0;

end

if  bj=0 and holding>0 and cond3 then sell(1,0,marketr);