什么条件下平掉剩下的一半?
请把平仓条件补充下,把1楼的完善后再写一遍。
input:n(2,1,100,1);
input:a(20,1,100,1);
input:m(10,0,200,5);
variable:bj=0;
tt:=time>=100000 and (time0<timetot0(closetime(0))-300);
h20:ref(hhv(h,20),1);
l20:ref(llv(l,20),1);
if tt and h>h20 then begin
sellshort(1,0,thisclose);
buy(holding=0,n,thisclose);
end
if tt and l<l20 then begin
sell(1,0,thisclose);
buyshort(holding=0,n,thisclose);
end
if holding>0 and enterprice-l>a then 止损多:sell(1,0,thisclose);
if holding<0 and h-enterprice>a then 止损空:sellshort(1,0,thisclose);
if bj=0 and holding=n and h-enterprice>m then begin
止盈多1:sell(1,n/2,thisclose);
bj:=1;
end
if bj=1 and holding=n/2 and l<l20 then begin
止盈后平多:sell(1,0,thisclose);
止盈多后反手:buyshort(holding=0,n,thisclose);
bj:=0;
end
if bj=0 and abs(holding)=n and enterprice-l>m then begin
止盈平空:sellshort(1,n/2,thisclose);
bj:=1;
end
if bj=1 and abs(holding)=n/2 and h>h20 then begin
止盈后平空:sellshort(1,0,thisclose);
止盈空后反手:buy(holding=0,n,thisclose);
bj:=0;
end
if time0>=timetot0(closetime(0))-300 then begin
收盘平仓空:sellshort(1,0,thisclose);
收盘平仓多:sell(1,0,thisclose);
end