HNL:=IF(HIGH>REF(HHV(HIGH,3),1),LOW,0);
L1:=IF(HNL>REF(L,1),REF(L,1),IF(HNL>REF(L,2),REF(L,2),IF(HNL>REF(L,3),REF(L,3),IF(HNL>REF(L,4),REF(L,4),0))));
L2:=IF(L1>REF(L,1),REF(L,1),IF(L1>REF(L,2),REF(L,2),IF(L1>REF(L,3),REF(L,3),IF(L1>REF(L,4),REF(L,4),0))));
L3:=VALUEWHEN(L2>0,L2);
LNH:=IF(LOW<REF(LLV(LOW,3),1),HIGH,666);
H1:=IF(LNH<REF(H,1),REF(H,1),IF(LNH<REF(H,2),REF(H,2),IF(LNH<REF(H,3),REF(H,3),IF(LNH<REF(H,4),REF(H,4),666))));
H2:=IF(H1<REF(H,1),REF(H,1),IF(H1<REF(H,2),REF(H,2),IF(H1<REF(H,3),REF(H,3),IF(H1<REF(H,4),REF(H,4),0))));
H3:=VALUEWHEN(H2>0,H2);
SEL:=VALUEWHEN((CLOSE>H3 and REF(CLOSE,1)<=H3)or(CLOSE<L3 and REF(CLOSE,1)>=L3),IF(CLOSE>H3 and REF(CLOSE,1)<=H3,1,0));
LINE:IF(SEL=1,L3,H3),COLORblue;
//开仓
long:= line<c and time>091400 and time<150500;
if long then
begin
sellshort(holding<0,holding,limitr,c);
buy(holding=0,1,limitr,c);
end
short:=line>c and time>091400 and time<150500;
if short then
begin
sell(holding>0,holding,limitr,c);
buyshort(holding=0,1,limitr,c);
end
sell(time>151200 and holding>0,0,thisclose);
sellshort(time>151200 and holding<0,0,thisclose);
PARTLINE( line<c, line, colorrgb(255,0,0));
PARTLINE( line>c, line, colorrgb(0,255,0));
DRAWNUMBER(ISLASTBAR,LINE,LINE,0,COLORblue);