顶底开关:=10;
自动预测周期:=5;
全画开关 :=6;
微调开关:=5;
AR1:=BARSCOUNT(C);
AR2:=CONST(AR1);
AR3:=AR2-AR1;
K线计数:AR3+1,NODRAW,COLORYELLOW;
XA:=(3*CLOSE+LOW+OPEN+HIGH)/6;
XA_1:=IF(结构带开关=1,XA,DRAWNULL);
B:(20*XA_1+19*REF(XA_1,1)+18*REF(XA_1,2)+17*REF(XA_1,3)+16*REF(XA_1,4)+15*REF(XA_1,5)+14*REF(XA_1,6)+13*REF(XA_1,7)+12*REF(XA_1,8)+11*REF(XA_1,9)+10*REF(XA_1,10)+9*REF(XA_1,11)+8*REF(XA_1,12)+7*REF(XA_1,13)+6*REF(XA_1,14)+5*REF(XA_1,15)+4*REF(XA_1,16)+3*REF(XA_1,17)+2*REF(XA_1,18)+REF(XA_1,20))/210,COLORMAGENTA,LINETHICK3;
D:MA(B,15),COLORFFFF00,LINETHICK3;
DRAWBAND(B,RGB(190,94,245),D,RGB(69,201,11));
DRAWKLINE(HIGH,OPEN,LOW,CLOSE);
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),COLORYELLOW;
STICKLINE(顶底开关>0 AND (KDJA <=10),CLOSE,OPEN,3,0),COLORBLUE;
XD:=B>D;
XY:=H>=B AND C>O AND L>D AND L<=B;
STICKLINE(XD AND XY,OPEN,CLOSE,3,0),COLORLIRED;
DRAWICON(XY AND XD,LOW,23);
A1:=(REF(HIGH,自动预测周期)=HHV(HIGH,(自动预测周期+1)));
B1:=FILTER(A1,自动预测周期);
C1:=BACKSET(B1,(自动预测周期+1));
D1:=FILTER(C1,自动预测周期);
A2:=(REF(LOW,自动预测周期)=LLV(LOW,(自动预测周期+1)));
B2:=FILTER(A2,自动预测周期);
C2:=BACKSET(B2,(自动预测周期+1));
D2:=FILTER(C2,自动预测周期);
E1:=(REF(LLV(LOW,自动预测周期),1)+REF(HHV(HIGH,自动预测周期),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);
{全画}
IF(全画开关=1,DRAWLINE(LD,L,HD,H,0),DRAWNULL)LINETHICK1,DOTLINE,COLOR0000FF;
IF(全画开关=1,DRAWLINE(HD,H,LD,L,0),DRAWNULL)LINETHICK1,DOTLINE,COLOR00FF00;
K:=CURRBARSCOUNT,NODRAW;
DRAWNUMBER(全画开关=1 AND HD,H,K),COLORLIRED,DRAWABOVE;
DRAWNUMBER(全画开关=1 AND LD,L,K),COLORFFFF00;
高点:=BARSLAST(HD);
低点:=BARSLAST(LD);
J1:=BACKSET(ISLASTBAR,MIN(高点,低点)+1);
J2:=J1>REF(J1,1);
高位价:=IF(微调开关=1,REF(REF(H,高点),1),DRAWNULL)COLORRED,NODRAW;
低位价:=IF(微调开关=1,REF(REF(L,低点),1),DRAWNULL)COLORGREEN,NODRAW;
H11:=高位价,NODRAW;
H12:=低位价,NODRAW;
L22:=DRAWNULL,NODRAW;
VVC1:=IF(高点<低点,H11,L22),NODRAW;
VVC2:=IF(LOW>低位价,H11,L22),NODRAW;
CL3:=VVC1 AND VVC2,COLOR00FFFF,NODRAW;
两点买入成立:=CL3,NODRAW;
高位价1:=IFC(CL3,H11,L22);
低位价1:=IFC(CL3,H12,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;
买C2:=CONST(VAR6),NODRAW;
买C3:=CONST(VAR7),NODRAW;
买入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('(低位)',VAR2STR(L,2))),COLORGREEN;
DRAWTEXT(VV2,H,VARCAT('(高位)',VAR2STR(H,2))),COLORRED;
STICKLINE(VV2,H,CONST(VAR7),0,-1),COLORFF8800;
IFC(CL3,DRAWLINE(VV,L,VV2,H,0),DRAWNULL),COLORFF8800,LINETHICK3;