以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  策略编写求助区  (http://weistock.com/bbs/list.asp?boardid=11)
----  公式编写  (http://weistock.com/bbs/dispbbs.asp?boardid=11&id=97654)

--  作者:dino
--  发布时间:2016/5/20 13:24:25
--  公式编写

当根K线收盘价大于前一K线收盘价3%(找出涨幅>3%K棒),后市若价格继续上涨1%,则开多单,若行情不再继续上涨,没达到开多条件,回调至上涨3% K棒的50%处,吞掉一半涨幅,则开空单

 

 

当根K线收盘价小于前一K线收盘价3%(找出跌幅>3%K棒),后市若价格继续下跌1%,则开空单,若行情不再继续下跌,没达到开空条件,反弹至下跌3% K棒的50%处,吞掉一半跌幅,则开多单

 

 

多单  动态跟踪回撤止损= 开仓后的最高收盘价向下回撤1.5%时止损

 

(如开多后当根K棒收盘价在10元,止损设在10元向下回撤1.5%处,下根K棒收盘价10.8元,则以新高收盘价10.8元向下回撤1.5%设为止损价,若后期收盘价创新高,则继续以新高收盘价向下回测1.5%设止损)

 

 

空单  动态跟踪回撤止损= 开仓后的最低收盘价向上反弹1.5%时止损


请老师帮忙编写公式模型,涨跌幅度,止损幅度修改方便,便于做测试


--  作者:jinzhe
--  发布时间:2016/5/20 13:55:25
--  

VARIABLE:bj=0;
nn1:=barslast((c-ref(c,1))/ref(c,1)>=0.03);
nn2:=barslast((ref(c,1)-c)/ref(c,1)>=0.03);

if (c-ref(c,1))/ref(c,1)>=0.03 then bj:=1;
if (ref(c,1)-c)/ref(c,1)>=0.03 then bj:=-1;

if bj=1 and nn1>0 and (c-ref(c,1))/ref(c,1)>0.01 then buy(holding=0,1,marketr);
if bj=1 and nn1>0 and c<=ref(ref(c,1)*1.015,nn1) then buyshort(holding=0,1,marketr);

if bj=-1 and nn2>0 and (ref(c,1)-c)/ref(c,1)>0.01 then buyshort(holding=0,1,marketr);
if bj=-1 and nn2>0 and c>-ref(ref(c,1)*0.985,nn2) then buy(holding=0,1,marketr);

if holding>0 and c<=hhv(h,enterbars+1)*1.015 then sell(1,0,marketr);
if holding<0 and c>=llv(l,enterbars+1)*0.985 then sellshort(1,0,marketr);


--  作者:dino
--  发布时间:2016/5/20 14:30:27
--  
老师,为何出信号的每根K线,开多,平多都在同一根K线