代码如下;
variable:cc=0;
ma1:=ma(ref(close,1),40);
h1:hhv(ref(h,1),20);
l1:llv(ref(low,1),20);
if cc=0 and tbc then begin //cc用来标识持仓。持有多单则为1,持有空单则为-1,无持仓则为0.
if h>h1 and h>ma1 then begin //开多
buyp:=max(o,h1);
buy(1,lots,limitr,buyp);
kcj:=buyp;
cc:=1;
end
else if l<l1 and l<ma1 then begin //开空
sellp:=min(o,l1);
buyshort(1,lots,limitr,sellp);
kcj:=sellp;
cc:=-1;
end
end
这样的代码为什么重复开仓。实盘。