//轨道/////////////////////
//k1:=0.45;k2:=0.35;
OpenNum:=barslast(day<>ref(day,1));
Highd:=ref(hhv(h,270/5),OpenNum+1);
LowD:=ref(llv(l,270/5),OpenNum+1);
CloseD:=ref(c,OpenNum+1);
OpenD:=ref(c,OpenNum);;
HH:= HHV(HighD,1);
HC:= HHV(CloseD,1);
LL:= LLV(LowD,1);
LC:= LLV(CloseD,1);
SellRange:=Max(HH - LC,HC - LL);
BuyRange:=Max(HH - LC,HC - LL);
上轨: OpenD + K1*BuyRange;
下轨: OpenD - K2*SellRange;
//上穿支撑平空,开多
kd:=cross(c,上轨);//开多
pk:=cross(c,上轨);//平空
//下穿压力平多,开空
pd:=cross(下轨,c);//平多
kk:=cross(下轨,c);//开空
//
if holding>0 and pd then sell(1,s,thisclose),IGNORECHECKPRICE,ORDERQUEUE;
if holding<0 and pk then sellshort(1,s,thisclose),IGNORECHECKPRICE,ORDERQUEUE;
if holding=0 and kd then buy(1,s,thisclose),IGNORECHECKPRICE,ORDERQUEUE;
if holding=0 and kk then buyshort(1,s,thisclose),IGNORECHECKPRICE,ORDERQUEUE;
//收盘前平仓
sell(time=145000 and holding>0,holding,market);
sellshort(time=145000 and holding<0,holding,market);