周期微调:=3;
高位C:=0;
低位D:=0;
手动开关:=1;
趋势线开关:=1;
顶底开关:=1;
DRAWTEXT_FIX(1,0.72,0.003,1,'说明: 如果自动选点不对,可按ALT+T键弹出参数调整窗,进行周期微调到符合点位,缺省值为“3”;顶底开关是开启或关闭黄色顶和蓝色底的信号之用。
高位C、低位D是手动输入k线根数,进行手动预测。'),COLORYELLOW;
AR1:=BARSCOUNT(C);
AR2:=CONST(AR1);
AR3:=AR2-AR1;
K线根数:AR3+1,NODRAW,COLORYELLOW;
kdjA :=3*SMA((CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100,3,1)-2*SMA(SMA((CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100,3,1),3,1),NODRAW;
STICKLINE(顶底开关>0 AND (kdJA >=90),CLOSE,OPEN,2.5,0),COLOR0088FF;
STICKLINE(顶底开关>0 AND (KDJA >=90),H,L,0,0),COLOR0088FF;
STICKLINE(顶底开关>0 AND (KDJA <=10),CLOSE,OPEN,2.5,0),COLORFF0000;
STICKLINE(顶底开关>0 AND (KDJA <=10),H,L,0,0),COLORFF0000;
A1:=REF(HIGH,周期微调)=HHV(HIGH,2*3+1);
B1:=FILTER(A1,周期微调);
C1:=BacKSET(B1,周期微调+1);
D1:=FILTER(C1,周期微调);
A2:=REF(LOW,周期微调)=LLV(LOW,2*3+1);
B2:=FILTER(A2,周期微调);
C2:=BACKSET(B2,周期微调+1);
D2:=FILTER(C2,周期微调);
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;
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 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);
A3:=H;
B3:=REF(H,REF(BARSLAST(HD),1)+1)>REF(H,REF(BARSLAST(HD),1)+2+REF(BARSLAST(HD),REF(BARSLAST(HD),1)+2));
D3:=A3 AND B3 AND HD;
E3:=BACKSET(D3,REF(BARSLAST(HD),1)+2);
HH:=E3>REF(E3,1);
A4:=L>REF(L,REF(BARSLAST(LD),1)+1);
B4:=REF(L,REF(BARSLAST(LD),1)+1); D4:=A4 AND B4 AND LD;
E4:=BACKSET(D4,REF(BARSLAST(LD),1)+2);
LL:=E4>REF(E4,1);
H3:=HH OR ISLASTBAR OR BARSCOUNT(C)=1;
X3:=REF(BARSLAST(H3),1)+1;
F3:=BACKSET(H3 AND COUNT(LL,X3)>0,LLVBARS(IF(LL,L,POW(10,20)),X3));
G3:=F3>REF(F3,1);
I3:=BACKSET(G3,2);
LZ:=I3>REF(I3,1);
L4:=LZ OR ISLASTBAR OR BARSCOUNT(C)=1;
X4:=REF(BARSLAST(L4),1)+1;
F4:=BACKSET(L4 AND COUNT(HH,X4)>0,HHVBARS(IF(HH,H,-POW(10,20)),X4));
G4:=F4>REF(F4,1);
I4:=BACKSET(G4,2);
HZ:=I4>REF(I4,1);
K1:=BACKSET(ISLASTBAR,MIN(BARSLAST(HZ),BARSLAST(LZ))+1);
K2:=K1>REF(K1,1);
UU:=BACKSET(ISLASTBAR,BARSLAST(LD)+1);
VV:=UU>REF(UU,1);
WW:=BACKSET(VV,REF(BARSLAST(LD),1)+2);
XX:=WW>REF(WW,1);
UU2:=BACKSET(ISLASTBAR,BARSLAST(HD)+1);
VV2:=UU2>REF(UU2,1);
WW2:=BACKSET(VV2,REF(BARSLAST(HD),1)+2);
XX2:=WW2>REF(WW2,1);
高点:=BARSLAST(HD);
低点:=BARSLAST(LD);
J1:=BACKSET(ISLASTBAR,MIN(高点,低点)+1);
J2:=J1>REF(J1,1);
IF(趋势线开关=1,DRAWLINE(LD,L,HD,H,0),DRAWNULL)LINETHICK1,DOTLINE,COLOR0000FF;
IF(趋势线开关=1,DRAWLINE(HD,H,LD,L,0),DRAWNULL)LINETHICK1,DOTLINE,COLORYELLOW;
K:=CURRBARSCOUNT,NODRAW;
DRAWNUMBER(趋势线开关=1 AND HD,H,K),COLORLIRED,DRAWAbovE;
DRAWNUMBER(趋势线开关=1 AND LD,L,K),COLORFFFF00;
高位价:REF(REF(H,高点),1),COLORRED,NODRAW;
低位价:REF(REF(L,低点),1),COLORGREEN,NODRAW;
GGA:=IFC(高点<低点 AND 高位价>低位价 AND LOW>=低位价,高位价,DRAWNULL);
LLA:=IFC(高点<低点 AND 高位价>低位价,低位价,DRAWNULL);
PB1A:=POW(LLA,0.382)*POW(GGA,0.618);
PB2A:=SQRT(LLA*GGA);
PB3A:=POW(LLA,0.618)*POW(GGA,0.382);
PB4A:=POW(LLA,0.875)*POW(GGA,0.125);
PB1:DRAWLINE(VV2,CONST(PB1A),CURRBARSCOUNT=1,CONST(PB1A),1),COLORFF8800,DOTLINE;
PB2:DRAWLINE(VV2,CONST(PB2A),CURRBARSCOUNT=1,CONST(PB2A),1),COLORFF8800,DOTLINE;
PB3:DRAWLINE(VV2,CONST(PB3A),CURRBARSCOUNT=1,CONST(PB3A),1),COLORFF8800,DOTLINE;
PB4:DRAWLINE(VV2,CONST(PB4A),CURRBARSCOUNT=1,CONST(PB4A),1),COLORFF8800,DOTLINE;
DRAWTEXT(VV2,CONST(PB1A),VARCAT('PB1=',VAR2STR(CONST(PB1A),2))),COLORWHITE;
DRAWTEXT(VV2,CONST(PB2A),VARCAT('PB2=',VAR2STR(CONST(PB2A),2))),COLORWHITE;
DRAWTEXT(VV2,CONST(PB3A),VARCAT('PB3=',VAR2STR(CONST(PB3A),2))),COLORWHITE;
DRAWTEXT(VV2,CONST(PB4A),VARCAT('PB4=',VAR2STR(CONST(PB4A),2))),COLORWHITE;
DRAWTEXT(VV,L,VARCAT('低位【A】',VAR2STR(L,2))),COLORGREEN;
DRAWTEXT(VV2,H,VARCAT('高位【B】',VAR2STR(H,2))),COLORRED;
STICKLINE(VV2,H,CONST(PB4A),0,0),COLORFF8800;
IFC(高点<低点 AND 高位价>低位价 AND LOW>=低位价,DRAWLINE(VV,L,VV2,H,0),DRAWNULL),COLORFF8800,LINETHICK2;
DRAWLINE(VV2,H,CURRBARSCOUNT=1,CONST(PB4A),0),COLORFF8800,DOTLINE;
DRAWICON(CURRBARSCOUNT=XX,L,38);
DRAWICON(CURRBARSCOUNT=VV2,H,39);
反弹高位:=REF(REF(H,高点),1),COLORRED,NODRAW;
反弹低位:=REF(REF(L,低点),1),COLORGREEN,NODRAW;
GGB:=IFC(高点>低点 AND 反弹高位>反弹低位 AND HIGH<=反弹高位,反弹高位,DRAWNULL);
LLB:=IFC(高点>低点 AND 反弹高位>反弹低位,反弹低位,DRAWNULL);
PS1B:=POW(GGB,0.382)*POW(LLB,0.618);
PS2B:=SQRT(GGB*LLB);
PS3B:=POW(GGB,0.618)*POW(LLB,0.382);
PS4B:=POW(GGB,0.875)*POW(LLB,0.125);
PS1:DRAWLINE(VV,CONST(PS1B),CURRBARSCOUNT=1,CONST(PS1B),1),COLORMAGENTA,DOTLINE;
PS2:DRAWLINE(VV,CONST(PS2B),CURRBARSCOUNT=1,CONST(PS2B),1),COLORMAGENTA,DOTLINE;
PS3:DRAWLINE(VV,CONST(PS3B),CURRBARSCOUNT=1,CONST(PS3B),1),COLORMAGENTA,DOTLINE;
PS4:DRAWLINE(VV,CONST(PS4B),CURRBARSCOUNT=1,CONST(PS4B),1),COLORMAGENTA,DOTLINE;
DRAWTEXT(VV,CONST(PS1B),VARCAT('PS1=',VAR2STR(CONST(PS1B),2))),COLORYELLOW;
DRAWTEXT(VV,CONST(PS2B),VARCAT('PS2=',VAR2STR(CONST(PS2B),2))),COLORYELLOW;
DRAWTEXT(VV,CONST(PS3B),VARCAT('PS3=',VAR2STR(CONST(PS3B),2))),COLORYELLOW;
DRAWTEXT(VV,CONST(PS4B),VARCAT('PS4=',VAR2STR(CONST(PS4B),2))),COLORYELLOW;
DRAWLINE(VV,L,CURRBARSCOUNT=1,CONST(PS4B),0),COLORMAGENTA,DOTLINE;
STICKLINE(VV,L,CONST(PS4B),0,0),COLORMAGENTA;
IFC(高点>低点 AND 反弹高位>反弹低位 AND HIGH<=反弹高位,DRAWLINE(VV2,H,VV,L,0),DRAWNULL),COLORMAGENTA,LINETHICK2;
DRAWICON(VV,L,38);
DRAWICON(VV2,H,39);