variable:a1=1;
tn:=1;//交易手數
cx:=1;//最大持倉量
xd:=3;//提前下單量(秒)
//交易時間區間
p1:=time>091500 and time<150000;
p2:=if(islastbar,dynainfo(207),time);
p3:=time0-timetot0(p2),linethick0;
r1:=barslast(date<>ref(date,1));
r2:=ref(o,r1);
hd:=if(islastbar,8,2.0);
hd1:=if(islastbar,3,0.2);
r10:=ref(asset,r1+1);
if r10-asset>3000 then a1:=-1;
if asset-r10>2000 then a1:=-1;
MA1:=MA(CLOSE,5);
MA2:=MA(CLOSE,25);
if a1<0 and p3<=xd then
begin
sell(1,tn,limitr,c-hd1);
sellshort(1,tn,limitr,c+hd1);
end
//*******************************
if cross(ma1,ma2) and a1>0 and p1 and p3<=xd then
begin
sellshort(holding<0,tn,limitr,c+hd1);
buy(holding=0,tn,limitr,c+hd1);
end
if cross(ma2,ma1) and a1>0 and p1 and p3<=xd then
begin
sell(holding>0,tn,limitr,c-hd1);
buyshort(holding=0,tn,limitr,c-hd1);
end
//**********收盤前清倉***********
if p2>=151000 then
begin
sellshort(holding<0,abs(holding),limitr,c+hd1);
sell(holding>0,holding,limitr,c-hd1);
a1:=1;
end