LP:=CURRBARSCOUNT =BC2 AND L=LOWER;{低点定位}
HP:=CURRBARSCOUNT =TC2 AND H=UPPER;{高点定位}
STICKLINE(IF(BC2 TC2,HP,LP),LOWER,UPPER,0,0),COLOR628962;
STICKLINE(IF(BC2 TC2,LP,HP),LOWER,UPPER,0,0),COLOR628962;
NOD:=(IF(TC2 BC2,TC2,BC2)-IF(TC2 BC2,BC2,TC2));{用时}
LR1:=FORCAST(C,NOD+1);
NP:IF(CURRBARSCOUNT =MAX(BC2,TC2),CONST(IF(MIN(TC2,BC2)=1,LR1,REF(LR1,MIN(TC2,BC2)-1))),DRAWNULL),POINTDOT,COLOR93BDA8;{近点}
LR2:=SLOPE(C,NOD+1);
LR3:=CONST(IF(MIN(TC2,BC2)=1,LR2,REF(LR2,MIN(TC2,BC2)-1)));
FP:NP-LR3*(NOD),POINTDOT,COLOR93BDA8;{远点}
EQU:(NP+FP)/2,POINTDOT,COLOR93BDA8;
AD:=ABS(NP-FP);{高差};
DBL:=BARSLAST(BC1!=DRAWNULL)+1;
DBH:=BARSLAST(TC1!=DRAWNULL)+1;
BSP:=IF(BC2 TC2,DBL,DBH)-1;
LRL:=IF(NP FP,FP+AD/NOD*BSP,FP-AD/NOD*BSP);
AT1:=IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND H LRL,H,LRL);
AT2:=HHV(AT1-LRL,MAX(BC2,TC2));
AT3:=CONST(BARSLAST(AT1-LRL=AT2));
AT4:=CONST(IF(AT3=0,H,REF(H,AT3)));
AT5:=CONST(IF(AT3=0,AT1-LRL,REF(AT1-LRL,AT3)));
ATL:=LRL+AT5;
UT1:=IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND L LRL,L,LRL);
UT2:=HHV(LRL-UT1,MAX(BC2,TC2));
UT3:=CONST(BARSLAST(LRL-UT1=UT2));
UT4:=CONST(IF(UT3=0,H,REF(H,UT3)));
UT5:=CONST(IF(UT3=0,LRL-UT1,REF(LRL-UT1,UT3)));
UTL:=LRL-UT5;
RH:=IF(CURRBARSCOUNT =MIN(BC2,TC2)-10,ATL,CONST(REF(ATL,MIN(BC2,TC2)-11)));{限制高}
RL:=IF(CURRBARSCOUNT =MIN(BC2,TC2)-10,UTL,CONST(REF(UTL,MIN(BC2,TC2)-11)));{限制低}
中轨:IF(NP FP,IF(LRL =RH,LRL,DRAWNULL),IF(LRL =RL,LRL,DRAWNULL)),COLOR628962;
上轨:IF(NP FP,IF(ATL =RH,ATL,DRAWNULL),IF(ATL =RL,ATL,DRAWNULL)),COLOR628962;
下轨:IF(NP FP,IF(UTL =RH,UTL,DRAWNULL),IF(UTL =RL,UTL,DRAWNULL)),COLOR628962;
{极品波浪指标,有此公式必发达}
A1:=REF(HIGH,3)=HHV(HIGH,2*3+1);
B1:=FILTER(A1,3);
C1:=BACKSET(B1,3+1);
D1:=FILTER(C1,3);{高点}
A2:=REF(LOW,3)=LLV(LOW,2*3+1);
B2:=FILTER(A2,3);
C2:=BACKSET(B2,3+1);
D2:=FILTER(C2,3);{低点}
E1:=(REF(LLV(LOW,2*3),1)+REF(HHV(HIGH,2*3),1))/2;
E2:=(HIGH+LOW)/2;
H1:=(D1 AND NOT((D2 AND E1 =E2))) OR ISLASTBAR OR BARSCOUNT(CLOSE)=1;
L1:=(D2 AND NOT((D1 AND E1 E2)));
H2:=D1 AND NOT((D2 AND E1 =E2));
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);{过滤后高点}
DRAWLINE(LD,L,HD,H,0),COLORMAGENTA,LINETHICK1;
DRAWLINE(HD,H,LD,L,0),COLORMAGENTA,LINETHICK1;
J1:=BACKSET(ISLASTBAR ,MIN(BARSLAST(HD),BARSLAST(LD))+1);
J2:=J1 REF(J1,1);
DRAWLINE(J2,IF(HD,H,L),ISLASTBAR ,IF(BARSLAST(HD) BARSLAST(LD),H,L),0),COLORWHITE,LINETHICK1;