谁能解释下这开平仓带止损的模型 看不懂怎么开仓的 想套用他的移动止损 我现在的模型有 kd kk pd pk 怎么套用移动止损呢
runmode:0;
variable:zs=0,cc=0,hl=0;
ma5:=ma(c,5);
ma20:=ma(c,20);
entertime:=time>100000 and time<144500;
if holding>0 and cc<=0 then sell(1,1,limitr,o);
if holding<0 and cc>=0 then sellshort(1,1,limitr,o);
if holding=0 and cc>0 then buy(1,1,limitr,o);
if holding=0 and cc<0 then buyshort(1,1,limitr,o);
if cc>0 and l<zs then begin
sell(1,1,limitr,min(o,zs-0.6));
cc:=0;
end
if cc<0 and h>zs then begin
sellshort(1,1,limitr,max(o,zs+0.6));
cc:=0;
end
if cc>0 and ma5<ma20 then cc:=0;
if cc<0 and ma5>ma20 then cc:=0;
if cc=0 and ma5>ma20 and entertime then begin
cc:=1;
zs:=c-10;
hl:=h;
end
if cc=0 and ma5<ma20 and entertime then begin
cc:=-1;
zs:=c+10;
hl:=l;
end
if cc>0 and h>hl then begin//创新高后,上移hl
hl:=h;
zs:=hl-10;
end
if cc<0 and l<hl then begin//创新低后,下移hl
hl:=l;
zs:=hl+10;
end
if time>=150000 then begin
cc:=0;
end
HL=High 就是这个意思
止损就是 high-10
low+10
空头与多头用了同一个变量HL ,所以开头才定义变量 HL=0
移动止损就是平仓条件, 新写一个平仓条件即可。
if holding>0 and cc<=0 then sell(1,1,limitr,o);
if holding<0 and cc>=0 then sellshort(1,1,limitr,o);
if holding=0 and cc>0 then buy(1,1,limitr,o);
if holding=0 and cc<0 then buyshort(1,1,limitr,o);
把你的条件替代进上面的4句话
if cc>0 and ma5<ma20 then cc:=0;
if cc<0 and ma5>ma20 then cc:=0;
if cc=0 and ma5>ma20 and entertime then begin
cc:=1;
zs:=c-10;
hl:=h;
end
if cc=0 and ma5<ma20 and entertime then begin
cc:=-1;
zs:=c+10;
hl:=l;
end
这部分该如何理解呢
1.如何把你的开平条件加进去,前面已经说过了,
if holding>0 and pd then sell(1,1,limitr,o);
if holding<0 and pk then sellshort(1,1,limitr,o);
if holding=0 and kd then buy(1,1,limitr,o);
if holding=0 and kk then buyshort(1,1,limitr,o);
2.你的移动止损嵌套不进去,要么用自己的,要么用上面的
if cc>0 and ma5<ma20 then cc:=0; if cc<0 and ma5>ma20 then cc:=0; if cc=0 and ma5>ma20 and entertime then begin |