周期微调:=5;
顶底开关:=1;
结构带开关:=1;
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,3,0),COLOR009CFF;
STICKLINE(顶底开关>0 AND (KDJA >=90),CLOSE,OPEN,2.8,0),COLOR009CFF;
STICKLINE(顶底开关>0 AND (KDJA >=90),CLOSE,OPEN,2.5,0),COLOR00C0FF;
STICKLINE(顶底开关>0 AND (KDJA >=90),CLOSE,OPEN,1.5,0),COLOR00D1FF;
STICKLINE(顶底开关>0 AND (KDJA >=90),CLOSE,OPEN,1,0),COLOR00EAFF;
STICKLINE(顶底开关>0 AND (KDJA >=90),CLOSE,OPEN,0.7,0),COLORYELLOW;
STICKLINE(顶底开关>0 AND (KDJA <=10),OPEN,CLOSE,3,0),COLORFF0000;
STICKLINE(顶底开关>0 AND (KDJA <=10),OPEN,CLOSE,2.5,0),COLORFF1100;
STICKLINE(顶底开关>0 AND (KDJA <=10),OPEN,CLOSE,2,0),COLORFF2200;
STICKLINE(顶底开关>0 AND (KDJA <=10),OPEN,CLOSE,1.5,0),COLORFF3300;
STICKLINE(顶底开关>0 AND (KDJA <=10),OPEN,CLOSE,1,0),COLORFF4400;
STICKLINE(顶底开关>0 AND (KDJA <=10),OPEN,CLOSE,0.5,0),COLORFF5500;
STICKLINE(顶底开关>0 AND (KDJA <=10),H,L,0,0),COLORFF6600;
A1:=REF(HIGH,周期微调)=HHV(HIGH,12+1);
B1:=FILTER(A1,周期微调);
C1:=BacKSET(B1,周期微调+1);
D1:=FILTER(C1,周期微调);{高点}
A2:=REF(LOW,周期微调)=LLV(LOW,10+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;{高低点出现在同一k线上时可作取舍}
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; {后面进行过滤,方法同前。只是不用考虑高低点出现在同一K线}
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);
NOTEXT1:DRAWLINE(LD,L,HD,H,0),LINETHICK1,DOTLINE,COLOR0000FF;
NOTEXT2:DRAWLINE(HD,H,LD,L,0),LINETHICK1,DOTLINE,COLOR00FF00;
NOTEXT3:DRAWLINE(J2,IF(HD,H,L),ISLASTBAR,IF(高点>低点,H,L),0),DOTLINE,COLORFFFFFF;
高位价:REF(REF(H,高点),1),COLORRED,NODRAW;
低位价:REF(REF(L,低点),1),COLORGREEN,NODRAW;
H11:=高位价,NODRAW;
H12:=低位价,NODRAW;
L22:=0,NODRAW;
VVA:=IF(高点<低点,H11,DRAWNULL)NODRAW;
买入成立:=VVA,COLOR00FFFF,NODRAW;
VVB:=IF(高点>低点,L22,DRAWNULL)NODRAW;
买入不成立:=VVB,COLORGREEN,NODRAW;
高位价1:=IFC(高点<低点,高位价,L22);
低位价1:=IFC(高点<低点,低位价,L22);
VAR1:=高位价1/低位价1;
VAR2:=SQRT(SQRT(VAR1));
VAR3:=SQRT(VAR1);
VAR4:=VAR3+VAR2-1;
VAR5:=高位价1/VAR2;
VAR6:=高位价1/VAR3;
VAR7:=高位价1/VAR4;
VAR8:=REFDATE(HHV(H,高点+1),DATE);
VAR9:=REFDATE(LLV(L,低点+1),DATE);
买C1:=CONST(VAR5),NODRAW,COLORYELLOW;
买C2:=CONST(VAR6),NODRAW,COLORYELLOW;
买C3:=CONST(VAR7),NODRAW,COLORYELLOW;
买入C1:DRAWLINE(VV2,CONST(买C1),CURRBARSCOUNT=1,买C1,1),COLORFF8800,DOTLINE;
买入C2:DRAWLINE(VV2,CONST(买C2),CURRBARSCOUNT=1,买C2,1),COLORFF8800,DOTLINE;
买入C3:DRAWLINE(VV2,CONST(买C3),CURRBARSCOUNT=1,买C3,1),COLORFF8800,DOTLINE;
DRAWTEXT(VV2,买C1,VARCAT('买入C1:',VAR2STR(买C1,2))),COLORWHITE;
DRAWTEXT(VV2,买C2,VARCAT('买入C2:',VAR2STR(买C2,2))),COLORWHITE;
DRAWTEXT(VV2,买C3,VARCAT('买入C3:',VAR2STR(买C3,2))),COLORWHITE;
DRAWTEXT(VV,L,VARCAT('低位【A】',VAR2STR(L,2))),COLORGREEN;
DRAWTEXT(VV2,H,VARCAT('高位【B】',VAR2STR(H,2))),COLORRED;
STICKLINE(VV2,H,CONST(VAR7),0,0),COLORFF8800;
DRAWLINE(VV,L,VV2,H,0),COLORFF8800,LINETHICK2;
DRAWLINE(VV2,H,CURRBARSCOUNT=1,CONST(VAR7),0),COLORGREEN,DOTLINE;
DRAWNUMBER(HD,H,H),DRAWAbovE,COLORFFFF00;
DRAWNUMBER(LD,L,L),COLOR00FFFF;
DRAWICON(CURRBARSCOUNT=XX,L,38);
DRAWICON(CURRBARSCOUNT=VV2,H,39);
高位价2:=REF(REF(H,高点),1),NODRAW;
低位价2:=REF(REF(L,低点),1),NODRAW;
H111:=高位价2,NODRAW;
H121:=低位价2,NODRAW;
L221:=0,NODRAW;
H221:=高位价2,NODRAW;
H231:=低位价2,NODRAW;
VVA1:=IF(高点>低点,H121,DRAWNULL)NODRAW;
卖出成立:=VVA1,COLOR00FFFF,NODRAW;
VVB1:=IF(高点<低点,L221,DRAWNULL)NODRAW;
卖出不成立:=VVB1,COLORGREEN,NODRAW;
高位价3:=IFC(高点>低点,高位价2,L221);
低位价3:=IFC(高点>低点,低位价2,L221);
VAR11:=高位价3/低位价3;
VAR21:=SQRT(SQRT(VAR11));
VAR31:=SQRT(VAR11);
VAR41:=VAR31+VAR21-1;
VAR51:=低位价3*VAR21;
VAR61:=低位价3*VAR31;
VAR71:=低位价3*VAR41;
卖C1:=CONST(VAR51),NODRAW,COLORMAGENTA,DOTLINE;
卖C2:=CONST(VAR61),NODRAW,COLORMAGENTA,DOTLINE;
卖C3:=CONST(VAR71),NODRAW,COLORMAGENTA,DOTLINE;
卖出C1:DRAWLINE(VV,CONST(卖C1),CURRBARSCOUNT=1,卖C1,1),COLORMAGENTA,DOTLINE;
卖出C2:DRAWLINE(VV,CONST(卖C2),CURRBARSCOUNT=1,卖C2,1),COLORMAGENTA,DOTLINE;
卖出C3:DRAWLINE(VV,CONST(卖C3),CURRBARSCOUNT=1,卖C3,1),COLORMAGENTA,DOTLINE;
DRAWTEXT(VV,卖C1,VARCAT('卖出C1:',VAR2STR(卖C1,2))),COLORYELLOW;
DRAWTEXT(VV,卖C2,VARCAT('卖出C2:',VAR2STR(卖C2,2))),COLORYELLOW;
DRAWTEXT(VV,卖C3,VARCAT('卖出C3:',VAR2STR(卖C3,2))),COLORYELLOW;
DRAWLINE(VV,L,CURRBARSCOUNT=1,CONST(VAR71),0),COLORMAGENTA,DOTLINE;
STICKLINE(VV,L,CONST(VAR71),0,0),COLORMAGENTA;
DRAWLINE(VV2,H,VV,L,0),COLORMAGENTA,LINETHICK2;
DRAWICON(VV,L,38);
DRAWICON(VV2,H,39);