P1:=18;NH:=1;
CC:=(2*CLOSE+HIGH+LOW)/4;
KS:=BARSCOUNT(CLOSE)+2;
M:=IF(KS P1,KS,P1);
GL:=Abs((M*CC-SUM(CC,M))/SUM(CC,M))+NH/453;
DTZQ:INTPART(NH/GL+0.5),NODRAW;
T:=DTZQ;
V5:=Ema(V,0.5*T);
V10:=EMA(V,2*T);
D1:=V REF(HHV(V,2),1) AND RANGE(V5,V10,V) AND UPNDAY(V5,2) AND UPNDAY(V10,2);
D2:=H REF(HHV(H,2),1);
KMAX:=MAX(C,O);
D3:=KMAX REF(HHV(KMAX,2),1);
DA:=D1 AND D2 AND D3;
PV1:=BArslAst(DA=1);
PV2:=REF(REF(H,1),PV1);
DB:=IF(DA,0,IF(C PV2,1,0));
TPX:REF(HHV(H,PV1+1),BARSLAST(DB AND T 40));
QSX:EMA(EMA(C,21),T),LINETHICK1,COLORFF00FF;