以文本方式查看主题

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

--  作者:DJX
--  发布时间:2015/5/26 15:18:29
--  移动止损的编写
老师好:我的系统开仓后有时获利了30个点,由于没到我的平仓条件,最后就成了亏损信号 ,我想把移动止损用到我的系统里面,就是获利20个点后,把止损移到开仓价,请问老师这个怎么写到系统里。
kd:=   806kd  ;
kk:=  806kk  ;
pd:= (enterprice-c>10 or (kk  ) or 801pd  ) ;
pk:=  (c-enterprice>10 or (kd ) or 801pk  )  ;
平空D:SELLSHORT((PK OR TIME>151300 ) AND HOLDING<0,HOLDING,MARKET);
平多D:SELL((PD  OR TIME>151200) AND HOLDING>0,HOLDING,MARKET);
开多D: BUY(kd and time<1455 AND HOLDING=0,1,MARKET);
开空D:BUYSHORT(kk and time<1455 AND HOLDING=0,1,MARKET);
 这是我这个系统的开平仓条件,请老师帮忙把移动止损写到系统里。

--  作者:jinzhe
--  发布时间:2015/5/26 15:25:40
--  

在原来的代码基础上,加上这几句:

 

if holding>0 and hhv(h,enterbars+1)>=enterprice+20 and l<=enterprice then sell(1,0,market);
if holding<0 and llv(l,enterbars+1)<=enterprice-20 and h>=enterprice then sellshort(1,0,market);

 

上面的是固定轮询模式下的。

如果系统用的是走完k线模式,则可以这样写:

 

if holding>0 and hhv(h,enterbars+1)>=enterprice+20 and c<=enterprice then sell(1,0,market);
if holding<0 and llv(l,enterbars+1)<=enterprice-20 and c>=enterprice then sellshort(1,0,market);


--  作者:DJX
--  发布时间:2015/5/26 15:40:23
--  
请问这两句要单独写个平仓语句吧?即:
kd:=   806kd  ;
kk:=  806kk  ;
pd:2= (enterprice-c>10 or (kk  ) or 801pd  ) ;
pk:2=  (c-enterprice>10 or (kd ) or 801pk  )  ;
PD1:=if holding>0 and hhv(h,enterbars+1)>=enterprice+20 and c<=enterprice then sell(1,0,market);
PK1:=if holding<0 and llv(l,enterbars+1)<=enterprice-20 and c>=enterprice then sellshort(1,0,market);
平空D:SELLSHORT((PK OR TIME>151300 ) AND HOLDING<0,HOLDING,MARKET);
PD:=PD1 OR PD2;
PK:=PK1 OR PK2;
平多D:SELL((PD  OR TIME>151200) AND HOLDING>0,HOLDING,MARKET);
开多D: BUY(kd and time<1455 AND HOLDING=0,1,MARKET);
请问这样对吗?

--  作者:jinzhe
--  发布时间:2015/5/26 15:47:11
--  
不是,我的意思是直接在你原来代码后面加这两句
--  作者:DJX
--  发布时间:2015/5/27 7:05:44
--  
请问这两句加在那里呢?就直接加在最后吗?
kd:=   806kd  ;
kk:=  806kk  ;
pd:2= (enterprice-c>10 or (kk  ) or 801pd  ) ;
pk:2=  (c-enterprice>10 or (kd ) or 801pk  )  ;
平空D:SELLSHORT((PK OR TIME>151300 ) AND HOLDING<0,HOLDING,MARKET);
PD:=PD1 OR PD2;
PK:=PK1 OR PK2;
平多D:SELL((PD  OR TIME>151200) AND HOLDING>0,HOLDING,MARKET);
开多D: BUY(kd and time<1455 AND HOLDING=0,1,MARKET);
if holding>0 and hhv(h,enterbars+1)>=enterprice+20 and c<=enterprice then sell(1,0,market);
if holding<0 and llv(l,enterbars+1)<=enterprice-20 and c>=enterprice then sellshort(1,0,market);
是这样吗?

--  作者:jinzhe
--  发布时间:2015/5/27 8:53:25
--  
kd:=   806kd  ;
kk:=  806kk  ;
pd:= (enterprice-c>10 or (kk  ) or 801pd  ) ;
pk:=  (c-enterprice>10 or (kd ) or 801pk  )  ;
平空D:SELLSHORT((PK OR TIME>151300 ) AND HOLDING<0,HOLDING,MARKET);
平多D:SELL((PD  OR TIME>151200) AND HOLDING>0,HOLDING,MARKET);
开多D: BUY(kd and time<1455 AND HOLDING=0,1,MARKET);
开空D:BUYSHORT(kk and time<1455 AND HOLDING=0,1,MARKET);
 

if holding>0 and hhv(h,enterbars+1)>=enterprice+20 and l<=enterprice then sell(1,0,market);
if holding<0 and llv(l,enterbars+1)<=enterprice-20 and h>=enterprice then sellshort(1,0,market);