一大推代码看着真累。
怎么连个开仓条件都没有啊?
还不如直接说出你的思路,我帮你写
看别人的代码比自己写代码难受多了
举个例子,突破hi20买入,lo20卖出 止损采用你的设置,代码如下:(30行不到的代码就搞定)
variable:zs=c,hl=c;
hi20:=ref(hhv(h,20),1);
lo20:=ref(llv(l,20),1);
if holding>0 and l<zs then sell(1,1,limitr,min(o,zs)-mindiff);//止损
if holding<0 and h>zs then sellshort(1,1,limitr,max(o,zs)+mindiff);//止损
if holding>0 and l<lo20 then sell(1,1,limitr,min(o,lo20)-mindiff);//离场
if holding<0 and h>hi20 then sellshort(1,1,limitr,max(o,hi20)+mindiff);//离场
if holding=0 and h>hi20 then begin//开多
buy(1,1,limitr,max(o,hi20)+mindiff);
hl:=h;//记录开仓后的最高点
zs:=enterprice-50*mindiff;//初始止损50个跳动点
end
if holding=0 and l<lo20 then begin//开空
buyshort(1,1,limitr,min(o,lo20)-mindiff);
hl:=l;//记录开仓后的最低点
zs:=enterprice+50*mindiff;//初始止损50个跳动点
end
if holding>0 and h>hl then begin//上移最高点
hl:=h;
if hl>enterprice+80*mindiff then zs:=hl-20*mindiff;//满80个点,回落20点为止损位
else if hl>enterprice+50*mindiff then zs:=hl-30*mindiff;//满50个点,回落30点为止损位
end
if holding<0 and l<hl then begin
hl:=l;
if hl<enterprice-80*mindiff then zs:=hl+20*mindiff;//满80个点,反弹20点为止损位
else if hl<enterprice-50*mindiff then zs:=hl+30*mindiff;//满50个点,反弹30点为止损位
end
[此贴子已经被作者于2011-7-25 10:47:28编辑过]