P:=15;
GT:=1;
DT:=1;
半径:=5;
DRAWTEXT_FIX(ISLASTBAR ,0.5,0.9,0,' 波 段 圆 主 图 '),COLORYELLOW;
P1:=IF(PERIOD<5 OR PERIOD=8,60,P);
A1:=REF(H,2)=HHV(H,P1) 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,P1) AND REF(L,2)<MIN(REF(L,1),L);
B2:=FILTER(A2,2);
C2:=BACKSET(B2,3);
D2:=FILTER(C2,2);{低点}
E1:=(REF(LLV(LOW,2*2),1)+REF(HHV(HIGH,2*2),1))/2;
E02:=(HIGH+LOW)/2; {高低点出现在同一K线上时可作取舍}
H1:=(D1 AND NOT((D2 AND E1>=E02))) OR ISLASTBAR OR BARSCOUNT(CLOSE)=1;
L1:=(D2 AND NOT((D1 AND E1<E02)));
H2:=D1 AND NOT((D2 AND E1>=E02));
X1:=REF(BARSLAST(H1),1)+1;
F1:=BACKSET(H1 AND COUNT(L1,X1)>0,LLVBARS(IF(L1,LOW,10000),X1));
G1:=F1>REF(F1,1);
I1:=BACKSET(G1,2);
LD:=I1>REF(I1,1);{过滤后低点}
L2:=LD OR ISLASTBAR OR BARSCOUNT(CLOSE)=1;
X2:=REF(BARSLAST(L2),1)+1;
F2:=BACKSET(L2 AND COUNT(H2,X2)>0,HHVBARS(IF(H2,HIGH,0),X2));
G2:=F2>REF(F2,1);
I2:=BACKSET(G2,2);
HD:=I2>REF(I2,1);{过滤后高点}
DRAWICON(LD,L*0.99,1);
DRAWICON(HD,H*1.01,2);
BDH:=REF(H,BARSLAST(HD));
BDL:=REF(L,BARSLAST(LD));
R11:=BACKSET(ISLASTBAR,BARSLAST(HD)+GT);
S11:=R11>REF(R11,1); {高}
T11:=BACKSET(ISLASTBAR,BARSLAST(LD)+DT);
U11:=T11>REF(T11,1); {低}
高点:REF(H,BARSLAST(S11)),COLOR00FF00;
低点:REF(L,BARSLAST(U11)),COLORFFCC00;
低天:=CONST(BARSLAST(U11));
高天:=CONST(BARSLAST(S11));
CURR:=CURRBARSCOUNT;
DRAWLINE(U11,L,S11,H,0),COLORYELLOW;
DRAWLINE(S11,H,U11,L,0),COLORWHITE;
SH:=CONST(高点);
SL:=CONST(低点);
高低差:=SH-SL;
天距:=ABS(低天-高天);
PR:=(高天+低天)/2;
RN:=(SH+SL)/2;
Y弧:=(SH*SL);
BX:=2*(SH*SL)/天距;
BY:=(SH*SL)/高低差;
XW:=IF(CURR<PR,PR-CURR,CURR-PR)*BX;
SY:=IF(XW<Y弧,SQRT(Y弧*Y弧-XW*XW),0)/BY/半径;
YX1:RN+SY,COLOR00FFFF;
YX2:RN-SY,COLOR00FFFF;