buycond:=count(c>o,2)=2;
sellcond:=count(c<o,2)=2;
if holding>0 and sellcond then sell(1,1,thisclose);
if holding<0 and buycond then sellshort(1,1,thisclose);
if holding=0 and buycond then buy(1,1,thisclose);
if holding=0 and sellcond then buyshort(1,1,thisclose);
老师,想在该策略上加入止损,一直弄不成,非常郁闷!
我的想法:入场后在次周期内如亏损5个点即时止损;在第二个周期内如亏损2个点即时止损;在第三个周期内如平本即时止损;在第四个周期内如盈利返回10%即时止盈。用于股指使用。
if enterbars=1 and enterprice-l>=5 then sell(holding>0,holding,market);
if enterbars=1 and h-enterprice>=5 then sellshort(holding<0,holding,market);
if enterbars=2 and enterprice-l>=2 then sell(holding>0,holding,market);
if enterbars=2 and h-enterprice>=2 then sellshort(holding<0,holding,market);
if enterbars=3 and enterprice-l>=0 then sell(holding>0,holding,market);
if enterbars=3 and h-enterprice>=0 then sellshort(holding<0,holding,market);
if enterbars=4 and h-enterprice>=0.1*enterprice then sell(holding>0,holding,market);
if enterbars=4 and enterprice-l>=0.1*enterprice then sellshort(holding<0,holding,market);
if enterbars=4 and h-enterprice>=0.1*enterprice then sell(holding>0,holding,market);
if enterbars=4 and enterprice-l>=0.1*enterprice then sellshort(holding<0,holding,market);
感谢老师!
有个地方改动一下,我不想在次周期开盘价执行止损,我想一当碰到了马上发出指令执行止损。这应该改为哪个?谢谢
我的想法:入场后在次周期内如亏损5个点即时止损;在第二个周期内如亏损2个点即时止损;在第三个周期内如平本即时止损;在第四个周期内如盈利返回10%即时止盈。用于股指使用。
老师,可能我写的不够明白,应该是次周期内如亏损5个点即时止损;在第二个周期内如比较上周期收盘价低2个点即时止损;在第三个周期内如比较上周期收盘价平本即时止损;在第四个周期内如盈利返回10%即时止盈。
已经止损了,就不能再开仓,这个公式放在系统内,经常出现平仓后又马上开仓的情况。
能不能用“止损”“止盈”符号在k线图中标识,如果是平空平多,很混乱。感谢老师!
意思和上周期收盘价先比而不是和开仓价相比止损?
盈利返回10%是指盈利开仓价的10%?
VARIABLE:n=0,m=0;
buycond:=count(c>o,2)=2;
sellcond:=count(c<o,2)=2;
c1:VALUEWHEN(enterbars=1,c);//开仓后下根k的收盘价
c2:VALUEWHEN(enterbars=2,c);//开仓后第二根k的收盘价
if holding>0 and sellcond then sell(1,1,thisclose);
if holding<0 and buycond then sellshort(1,1,thisclose);
if holding=0 and n=0 and buycond then buy(1,1,thisclose);
if holding=0 and m=0 and sellcond then buyshort(1,1,thisclose);
if enterbars=1 and enterprice-l>=5 then begin
sell(holding>0,holding,market);
n:=1;
end
if enterbars=1 and h-enterprice>=5 then begin
sellshort(holding<0,holding,market);
m:=1;
end
if enterbars=2 and c1-l>=2 then begin
sell(holding>0,holding,market);
n:=1;
end
if enterbars=2 and h-c1>=2 then begin
sellshort(holding<0,holding,market);
m:=1;
end
if enterbars=3 and c2-l>=0 then begin
sell(holding>0,holding,market);
n:=1;
end
if enterbars=3 and h-c2>=0 then begin
sellshort(holding<0,holding,market);
m:=1;
end
if enterbars=4 and h-enterprice>=0.1*enterprice then begin
sell(holding>0,holding,market);
n:=1;
end
if enterbars=4 and enterprice-l>=0.1*enterprice then begin
sellshort(holding<0,holding,market);
m:=1;
end
if time=CLOSETIME(0) then begin//止损后不开仓第二天再开仓
n:=0;
m:=0;
end