variable:n=0;
if 开多条件 and n=0 and holding=0 then begin
buy......;
n:=1;
end
if 开空条件 and n=0 and holding=0 then begin
buyshort.....;
n:=1;
end
if 平多条件 then sell.....;
if 平空条件 then sellshort....;
if n=1 and type(1)=4 then buy.......;
if n=1 and type(1)=2 then buyshort......;