Variable:PositionCount=0;
开多条件:=holding=0 and cond1;
开空条件:=holding=0 and cond11;
Buy(开多条件,how,marketr);
buyshort(开空条件,how,marketr);
If ENTERBARS=0 then PositionCount=PositionCount+1;
If PositionCount=1 then begin;
If holding>0 and cond2 then begin;
Buy(1,how,marketr);
PositionCount=PositionCount+1;
End;
If holding<0 and cond22 then begin;
buyshort(1,how,marketr);
PositionCount=PositionCount+1;
End;
End;
If PositionCount=2 then begin;
If holding>0 and cond3 then begin;
Buy(1,how,marketr);
PositionCount=PositionCount+1;
End;
If holding<0 and cond33 then begin;
buyshort(1,how,marketr);
PositionCount=PositionCount+1;
End;
End;
//平仓
If holding<>0 then begin;
Sell(多仓止损条件,0,marketr);
Sellshort(空仓止损条件,0,marketr);
End;
If holding=0 then PositionCount=0;