老师好:我的系统开仓后有时获利了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);
这是我这个系统的开平仓条件,请老师帮忙把移动止损写到系统里。
在原来的代码基础上,加上这几句:
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);
请问这两句要单独写个平仓语句吧?即:
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);
请问这样对吗?
请问这两句加在那里呢?就直接加在最后吗?
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);
是这样吗?
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);