|
1楼
![](static/image/common/ico_lz.png)
楼主 |
发表于 2011-12-27 20:50:56
|
只看该作者
本帖最后由 火焰之神 于 2015-4-8 16:54 编辑
二、移动止损的编写方法:
还是以之前的模型为例,希望加入移动止损,即:开仓后的最高点回落10个点要盘中止损离场
加入一个全局变量 hl,记录开多后的最高点,开空后的最低点:
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
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 ma5ma20 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 hl:=l;
end
if cc>0 and h>hl then begin//创新高后,上移hl
hl:=h;
zs:=hl-10;
end
if cc<0 and l
hl:=l;
zs:=hl+10;
end
if time>=150000 then begin
cc:=0;
end
|
|