XXX:=20;
HH:=H>=HV(H,XXX) &&H>=REFX(HHV(H,XXX),XXX) ;
LL:=L<=LV(L,XXX) &&L<=REFX(LLV(L,XXX),XXX) ;
HHH:=IF(HH,H,0);
LLL:=IF(LL,L,99999);
NH:=BARSLAST(HH)+1;
NL:=BARSLAST(LL)+1;
AH:BACKSET(COUNT(HH,SUMBARS(LL,2))>=1&&LL,HHVBARS(HHH,SUMBARS(LL,2))+1);//低点前第一个高点
AL:BACKSET(COUNT(LL,SUMBARS(HH,2))>=1&&HH,LLVBARS(LLL,SUMBARS(HH,2))+1);//高点前第一个低点
N1:=BACKSET(ISLASTBAR&&BARSLAST(LL)<BARSLAST(HH),LLVBARS(LLL,BARSLAST(HH))+1);
N2:=BACKSET(ISLASTBAR&&BARSLAST(LL)>BARSLAST(HH),HHVBARS(HHH,BARSLAST(LL))+1);
HHHH:=CROSS(AH=1,0.5)||CROSS(N2=1,0.5);
LLLL:=CROSS(AL=1,0.5)||CROSS(N1=1,0.5);
DRAWLINE1(HHHH,H,LLLL,L,0),LINETHICK3,COLORGREEN;
DRAWLINE1(LLLL,L,HHHH,H,0),LINETHICK3,COLORRED;
HH1:=REF(H,SUMBARS(HHHH,1)-1);
HH2:=REF(H,SUMBARS(HHHH,2)-1);
LL1:=REF(L,SUMBARS(LLLL,1)-1);
LL2:=REF(L,SUMBARS(LLLL,2)-1);
DRAWSL(ISLASTBAR,LL1+(HH1-LL1)*1.382,0,-SUMBARS(HHHH,1),0,COLORRED),DOT;
DRAWNUMBER(ISLASTBAR,LL1+(HH1-LL1)*1.382,LL1+(HH1-LL1)*1.382,2,COLORRED),VALIGN2;
DRAWSL(ISLASTBAR,LL2+(HH2-LL2)*1.382,0,-SUMBARS(HHHH,2),0,COLORRED),DOT;
DRAWNUMBER(ISLASTBAR,LL2+(HH2-LL2)*1.382,LL2+(HH2-LL2)*1.382,2,COLORRED),VALIGN2;