KD:=REF(high>=REF(high,1),1) ;
KK:=REF(high<REF(high,1),1);
//开多止盈5
IF H-ENTERPRICE>=5*MINDIFF and
holding>0 THEN BEGIN
SELL(1,0,MARKET),orderQueue;
END
//开空止盈5
IF ENTERPRICE-low>=5*MINDIFF and
holding<0 THEN BEGIN
sellshort(1,0,MARKET),orderQueue;
END
//开多止损20
IF ENTERPRICE-low>=20*MINDIFF and
holding>0 THEN BEGIN
SELL(1,0,MARKET),orderQueue;
END
//开空止损20
IF HIGH-ENTERPRICE>=20*MINDIFF and
holding<0 THEN BEGIN
sellshort(1,0,MARKET),orderQueue;
END
//------------------开多
if (KD AND HOLDING=0) then
begin
BUY(1 ,手数,marketr),orderQueue;
end
//-----------------开空
if (KK AND HOLDING=0) then
begin
BUYSHORT(1,手数,marketr),orderQueue;
end
//-----------------------------k走完提前2秒平仓
abb:=(time0-timetot0(dynainfo(207))<=2)
or not(islastbar); //tq是设定的提前下单的秒数
if abb then begin
sell(1,0,MARKET),orderQueue;
sellshort(1,0,MARKET),orderQueue;
END