if (CS>CS1 or (nTE<=nTE1-0.4)) then begin//排名下降,下跌一个区间//nBE改成nTE
bc:=if(TISPRVREMAIN(2)=1 and TORDERPRICE(2,1)=TE,1,0);
so:=if(TISPRVREMAIN(3)=1 and TORDERPRICE(3,1)=TE,1,0);
if tholding2<e then begin
if tholding2>-e then begin
if tholding2<=0 then begin
if tbuyholding(1)>0 then begin
if bc=0 then tsell(nTE-close>m,1,lmt,TE);
bc:=1;so:=1;
end
if tbuyholding(1)=0 then begin
if so=0 then tbuyshort(nTE-close>m,1,lmt,TE);
so:=1;bc:=1;
end
end
if tholding2=1 then begin
if tbuyholding(1)>1 then begin
if bc=0 then tsell(nTE-close>m,2,lmt,TE);
bc:=1;so:=1;
end
if tbuyholding(1)=1 then begin
if bc=0 then tsell(nTE-close>m,1,lmt,TE);
bc:=1;
if so=0 then tbuyshort(nTE-close>m,1,lmt,TE);
so:=1;
end
if tbuyholding(1)=0 then begin
if so=0 and bc=0 then tbuyshort(nTE-close>m,2,lmt,TE);
bc:=1;so:=1;
end
end
if tholding2>1 then begin
if tbuyholding(1)>=2 then begin
if bc=0 then tsell(nTE-close>m,2,lmt,TE);
bc:=1;
if so=0 then tbuyshort(nTE-close>m,1,lmt,TE);
so:=1;
end
if tbuyholding(1)=1 then begin
if bc=0 then tsell(nTE-close>m,1,lmt,TE);
bc:=1;
if so=0 then tbuyshort(nTE-close>m,1,lmt,TE);
so:=1;
end
if tbuyholding(1)=0 then begin
if bc=0 and so=0 then tbuyshort(nTE-close>m,2,lmt,TE);
bc:=1;so:=1;
end
end
end
if tholding2<=-e then begin//极限再平多开空
if ERSI1<=32 then so:=1;
if bc=0 and ERSI1>32 and tbuyholding(1)>1 then begin
tsell(nTE-close>m,2,lmt,TE);
bc:=1;
end
if bc=0 and ERSI1>32 and tbuyholding(1)=1 then begin
tsell(nTE-close>m,1,lmt,TE);
bc:=1;
end
if so=0 and ERSI1ms>32 then begin
tbuyshort(nTE-close>m,1,lmt,TE);
so:=1;
end
end
end
if tholding2>=e and taccount(4)<0 and ERSI1>-32 and down=1 then begin
if bc=0 and tbuyholding(1)>2 then begin
tsell(nTE-close>m,3,lmt,TE);
bc:=1;
so:=1;
end
if bc=0 and tbuyholding(1)>1 then begin
tsell(nTE-close>m,2,lmt,TE);
bc:=1;
end
if bc=0 and tbuyholding(1)=1 then begin
tsell(nTE-close>m,1,lmt,TE);
bc:=1;
end
if so=0 then begin
tbuyshort(nTE-close>m,1,lmt,TE);
tbuyshort(nTE-close>m,1,lmt,TE);
tbuyshort(nTE-close>m,1,lmt,TE);
so:=1;
end
end
end