variable:n:=0;
variable:nn:=0;
xx:nn,noaxis;
ll:=hhv(h,todaybar);
if L<=ll-4 and n=0 then begin
buyshort (holding=0,1,limitr,ll-4);
n:=1;
end
gg:llv(l,enterbars+1);//,noaxis;
if h>=gg+4 and nn=0 then begin
sellshort(holding<0,0,limitr,gg+4);
nn:=1;
end
sell(time>150000 and holding>0, 0, market);
sellshort(time>150000 and holding<0, 0, market);
if time=closetime(0) then begin
n:=0;
nn:=0;
end
请问上面代码哪里不对?
红色部份无法平空,去掉nn:=1就可以
加上nn:=1,xx输出时开盘第一K时nn=0,其它都为1
可否回答一下
加上nn:=1,xx输出时开盘第一K时nn=0,其它都为1
因为开盘时nn赋值为0 所以第一根nn输出为0
之后h>=gg+4 and nn=0条件满足nn赋值为1,并且没有再复制为0,一直到第二天开盘又赋值为0.
把holding<0的判断放在then前,这样是平仓后nn赋值为1
if h>=gg+4 and nn=0 and holding<0 then begin
sellshort(1,0,limitr,gg+4);
nn:=1;
end