A:=(3*CLOSE+LOW+OPEN+HIGH)/6;
HH1:= IFELSE (H<REF(H,2)&&REF(H,1)<REF(H,2),REF(H,2),0);
LL1:= IFELSE (L>REF(L,2)&&REF(L,1)>REF(L,2),REF(L,2),0);
HH2:=VALUEWHEN(HH1>0,HH1);
LL2:=VALUEWHEN(LL1>0,LL1);
KA1:= IFELSE (CLOSE>HH2,-3,IFELSE(CLOSE<LL2,1,0));
KA2:=VALUEWHEN(KA1<>0,KA1);
HO:= HIGH >REF( HIGH,1) &&HIGH >REF(HIGH,2) && HIGH >=REFX(HIGH,1) && IFELSE(HIGH =REFX(HIGH,2), HIGH >REFX(HIGH,3), HIGH >REFX(HIGH,2));
FXH:=CROSS(HO,0.9);
HH:=REF(HIGH,BARSLAST(FXH));
LO:= LOW<REF(LOW,1) && LOW <REF(LOW,2) && LOW <=REFX(LOW,1) && IFELSE(LOW =REFX(LOW,2), LOW <REFX(LOW,3), LOW <REFX(LOW,2));
FXL:=CROSS(LO,0.9);
LL:=REF(LOW,BARSLAST(FXL));
STICKLINE(CLOSE,HH,HH-0.0001,COLORMAGENTA,0);
STICKLINE(CLOSE,LL,LL-0.0001,COLORLIGHTBLUE,0);
AUTOFILTER;