variable:n=0;
if n=0 and 开多条件 then begin
buy.........;
n:=1;
end
if n=0 and 开空条件 then begin
buy..........;
n:=1;
end
if n=1 and 开多条件 and enterbars>0 and exitbars>0 then begin
buy.......;
end
if n=1 and 开空条件 and enterbars>0 and exitbars>0 then begin
buyshort.......;
end
if n=1 and 平多条件 and enterbars>0 and exitbars>0 then begin
sell.......;
end
if n=1 and 平空条件 and enterbars>0 and exitbars>0 then begin
sellshort.......;
end