//前20分鐘 ()的高低區間濾網.
if time=tt then begin
dh=highd(0)
dl=lowd(0)
end;
//做多條件成立:: 收盤價向上突破下軌線var1==> 作多
if close crosss over var1 then begin
condition3=true;
condition4=false;
end;
//做空條件成立:: 收盤價向下跌破上軌線var0==> 作空
if close crosss under var0 then begin
condition4=true;
condition3=false;
end;
//高點 >今低價+ (1.5倍* 過去30根ATR)==> 作多
if time<1315 and condition3=true and low>=dl
and high>lowd(0)+1.5 * avgtruerange(aa) then
buy next bar at highest(high,3) +1 stop;
//低點 >今高價- (1.5倍* 過去30根ATR)==> 作空
if time<1315 and condition4=true and high>=dh
and low>highd(0)-1.5 * avgtruerange(aa) then
sellshort next bar at highest(high,3) -1 stop;
//若是有多單==> 固定點數停損
if marketposition>0 then
sell next bar at entryprice - fixLost stop;
//若是有空單==> 固定點數停損
if marketposition<0 then
buytocover next bar at entryprice + fixLost stop;
//如果是結算日 自動平倉
condition9=dayofweek(date)=3
and dayofmonth(date)>14
and dayofmonth(date)<22
or date=1040127 or date=1070226
or date=1100617 or date=1100222;
//if condition9=true then begin
if time>1335 then begin
sell this bar on close;
buytocover this bar on close;
end;
//end;