H1:=9;
H2:=1;
L1:=9;
L2:=1;
N:=2;
M:=2;
DRAWTEXT_FIX(ISLASTBAR,0.1,0.1,0,HYBLOCK),COLOR00FF00;
DRAWTEXT_FIX(ISLASTBAR,0,0.1,0,DYBLOCK),COLORWHITE;
DRAWTEXT_FIX(ISLASTBAR,0.0,0,0,GNBLOCK),COLORYELLOW;
M5:EMA(C,5),COLORYELLOW;
M34:EMA(C,34),COLORFF00FF;
P:=IF(PERIOD<5 OR PERIOD=8,36,7);
A1:=REF(H,2)=HHV(H,P) AND REF(H,2)>MAX(REF(H,1),H);
B1:=FILTER(A1,2);
C1:=BACKSET(B1,3);
D1:=FILTER(C1,2);{高点}
A2:=REF(L,2)=LLV(L,P) AND REF(L,2)<MIN(REF(L,1),L);
B2:=FILTER(A2,2);
C2:=BACKSET(B2,3);
D2:=FILTER(C2,2);{低点}
BDH:=REF(H,BARSLAST(D1));
BDL:=REF(L,BARSLAST(D2));
SS:IF(C>BDH,BDH*BDH/BDL,IF(C<BDL,BDL*BDL/BDH,SQRT(BDH*BDL))),COLORWHITE,DOTLINE;
DRAWICON(D1,H*1.005,1);
DRAWICON(D2,L*0.995,2);
DRAWLINE(CURRBARSCOUNT=H1,H,CURRBARSCOUNT=H2,H,1),COLORWHITE;
DRAWLINE(CURRBARSCOUNT=L1,L,CURRBARSCOUNT=L2,L,1),COLOR00CCFF;
R11:=BACKSET(ISLASTBAR,BARSLAST(D1)+1);
S11:=R11>REF(R11,1); {高}
WW:=BACKSET(S11,REF(BARSLAST(D1),1)+N);
XX:=WW>REF(WW,1); {前高}
T11:=BACKSET(ISLASTBAR,BARSLAST(D2)+1);
U11:=T11>REF(T11,1); {低}
WL:=BACKSET(U11,REF(BARSLAST(D2),1)+M);
XL:=WL>REF(WL,1); {前低}
前高:REF(H,BARSLAST(XX)),COLOR00FF00;
前低:REF(L,BARSLAST(XL)),COLORFFCC00;
涨停:=IF(1.1*REF(C,1)-C<0.01,1,0);
STICKLINE(涨停,O,C,1,0),COLOR0099FF;
跌停:=IF(C-0.9*REF(C,1)<0.01,1,0);
STICKLINE(跌停,O,C,1,0),COLORBLUE;