{顶底反转K线 }
笔周期:=3; 画趋势:=0;
AA1:=REF(HIGH,3)=HHV(HIGH,笔周期*3+1);
BBA1:=FILTER(AA1,3);
C1:=BACKSET(BBA1,3+1);
D1:=FILTER(C1,3);{高点}
AZ2:=REF(LOW,3)=LLV(LOW,笔周期*3+1);
B2:=FILTER(AZ2,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;{高低点出现在同一K线上时可作取舍}
H1:=(D1 AND NOT(D2 AND E1>=E2)) OR BARSTATUS=2 OR BARSCOUNT(CLOSE)=1;
H2:=D1 AND NOT(D2 AND E1>=E2);
L1:=D2 AND NOT(D1 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 BARSTATUS=2 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); {过滤后高点}
STICKLINE(HD,O,C,2.9,1),COLORFFFFFF;
STICKLINE(HD,O,C,1.7,0),COLORFFFFFF;
STICKLINE(LD,O,C,2.9,1),COLOR00FF00;
STICKLINE(LD,O,C,1.7,0),COLOR00FF00;
MA5:MA(C,5),COLOR00FF00;
MA10:MA(C,10),COLOR00DDDD;
MA20:MA(C,20),COLORF00FF0;