当天开仓一笔有利,就不开第二笔了,如果当天第一笔止损,就还开第二笔。
variable:n=0;
variable:m=0;
if date<>ref(date,1) then n:=0;
if duo and n<=1 and m=0 and h>=cpj+qatr/3 and (holding=0 or holding=1*ENTERVOL) and time<145500 then begin
sellshort(1,0,market);
buy(1,1,market);
n:=n+1;
m:=1;
end
s:=ref(qatr,enterbars);
if L<=ENTERPRICE-s/3 and enterbars>0 then begin
sell(1,entervol,market);
m:=0;
end
if hhv(h,enterbars+1)>=ENTERPRICE+s/3 and l<=ENTERPRICE and enterbars>0 then begin
sell(1,entervol,market);
m:=0;
end
if time>=150000 then begin
n:=0;
m:=0;
end
这样写,第一笔有利的情况下,为什么还会开第二笔,请帮我看一下哪里写错了?
我的思路是日内交易限制两次,有利的交易限制一次。第一笔止损或保本,可以开第二笔,第一笔有利,日内就不可以开第二笔了。
你把类似的 enterprice+s/3的,都给括号括起来
variable:n=0;
variable:m=0;
if date<>ref(date,1) then n:=0;
if duo and n<=1 and m=0 and h>=(cpj+qatr/3) and (holding=0 or holding=1*ENTERVOL) and time<145500 then begin
sellshort(1,0,market);
buy(1,1,market);
n:=n+1;
m:=1;
end
s:=ref(qatr,enterbars);
if L<=(ENTERPRICE-s/3) and enterbars>0 then begin
sell(1,entervol,market);
m:=0;
end
if hhv(h,enterbars+1)>=(ENTERPRICE+s/3) and l<=ENTERPRICE and enterbars>0 then begin
sell(1,entervol,market);
m:=0;
end
if kong and n<=1 and m=0 and l<=(cpj-qatr/3) and (holding=0 or holding=-1*ENTERVOL) and time<145500 then begin
sell(1,0,market);
buyshort(1,1,market);
n:=n+1;
m:=1;
end
s:=ref(qatr,enterbars);
if h>=(ENTERPRICE+s/3) and enterbars>0 then begin
sellshort(1,entervol,market);
m:=0;
end
if llv(h,enterbars+1)<=(ENTERPRICE-s/3) and h>=ENTERPRICE and enterbars>0 then begin
sellshort(1,entervol,market);
m:=0;
end
if time>=150000 then begin
n:=0;
m:=0;
end
if L<=(ENTERPRICE-s/3) and enterbars>0 then begin
sell(1,entervol,market);
m:=0;
end
这个是不是能够继续开仓的平仓止损?
把这些类似的都加一个持仓判断在外面,写成这样
if L<=(ENTERPRICE-s/3) and enterbars>0 and holding>0 then begin
sell(1,entervol,market);
m:=0;
end
空头是<0