M5:=MA(C,5);M10:=MA(C,10);H5:=REF(H,5)=HHV(H,11);L5:=REF(L,5)=LLV(L,11);Q1:=BACKSET(H5,6)>BACKSET(H5,5) ;Q2:=BACKSET(L5,6)>BACKSET(L5,5) ;Q3:=IF(BARSLAST(Q1)=BARSLAST(Q2) AND M5>M10,Q1,IF(BARSLAST(Q2)>BARSLAST(Q1),Q1,0));Q4:=IF(BARSLAST(Q1)=BARSLAST(Q2) AND M10>M5,Q2,IF(BARSLAST(Q1)>BARSLAST(Q2),Q2,0));Q5:=Q3 AND H=HHV(H,BARSLAST(Q4));Q6:=Q4 AND L=LLV(L,BARSLAST(Q3));G:=L>REF(H,1) AND DAY!=REF(DAY,1);D:=H<REF(L,1) AND DAY!=REF(DAY,1);GH:=REF(H,BARSLAST(Q5));GL:=REF(L,BARSLAST(Q5));GH1:=REF(H,BARSLAST(Q5)+1);GL1:=REF(L,BARSLAST(Q5)+1);GH2:=REF(H,BARSLAST(Q5)+2);GL2:=REF(L,BARSLAST(Q5)+2);DH:=REF(H,BARSLAST(Q6));DL:=REF(L,BARSLAST(Q6));DH1:=REF(H,BARSLAST(Q6)+1);DL1:=REF(L,BARSLAST(Q6)+1);DH2:=REF(H,BARSLAST(Q6)+2);DL2:=REF(L,BARSLAST(Q6)+2);GZH:=IF(GL<=GL1,GH2,GH1);GZL:=IF(GH1<GL,GL,IF(GL<=GL1,GL2,GL1));DZH:=IF(DL1>DH,DH,IF(DH>=DH1,DH2,DH1));DZL:=IF(DH>=DH1,DL2,DL1);GA1:=GH>DZH AND Q5;DA1:=DL<GZL AND Q6;GA:=GA1 AND GH>DH AND GL>DL AND GL1>DL;DA:=DA1 AND DL<GL AND DH<GH AND DH1<GH;B0:=(H<=REF(H,1) AND L>=REF(L,1)) OR (H>=REF(H,1) AND L<=REF(L,1));BG:=COUNT(B0,BARSLAST(Q6));BD:=COUNT(B0,BARSLAST(Q5));BQ:=COUNT(G,BARSLAST(Q6));DQ:=COUNT(D,BARSLAST(Q5));K0:=IF(BG>0,BG+2+1,IF(BD,BD+2+1,3));BB:=IF(BQ,K0-BQ,IF(DQ,K0-DQ,K0));HX:=(GA AND BARSLAST(DA)>BB);LX:=(DA AND BARSLAST(GA)>BB);G1:=(Q5 AND REF(H,BARSLAST(Q5))>=REF(H,BARSLAST(HX)) AND BARSLAST(LX)>BARSLAST(HX))OR (GA1 AND COUNT(G,BARSLAST(DA1))>0 AND REF(H,BARSLAST(GA1))>REF(H,BARSLAST(HX)));D1:=(Q6 AND REF(L,BARSLAST(Q6))<=REF(L,BARSLAST(LX)) AND BARSLAST(HX)>BARSLAST(LX))OR (DA1 AND COUNT(D,BARSLAST(GA1))>0 AND REF(L,BARSLAST(DA1))<REF(H,BARSLAST(LX)));G1H:=IF(BARSLAST(DA1)>BARSLAST(GA1),REF(H,BARSLAST(GA1)),REF(H,BARSLAST(DA1))),;D1L:=IF(BARSLAST(GA1)>BARSLAST(DA1),REF(L,BARSLAST(DA1)),REF(L,BARSLAST(GA1)));G2:=G1 AND H=HHV(G1H,BARSLAST(DA1)+1) AND H>REF(H,1) AND BARSLAST(DA1)>BARSLAST(GA1);D2:=D1 AND L=LLV(D1L,BARSLAST(GA1)+1) AND L<REF(L,1) AND BARSLAST(GA1)>BARSLAST(DA1);G3:=G2 OR (Q5 AND REF(H,BARSLAST(Q5))>REF(H,BARSLAST(G2)) AND BARSLAST(D2)>BARSLAST(G2));D3:=D2 OR (Q6 AND REF(L,BARSLAST(Q6))<REF(L,BARSLAST(D2)) AND BARSLAST(G2)>BARSLAST(D2));GT:=BARSLAST(G3);DT:=BARSLAST(D3);GB:=HHV(H,2);DB:=HHV(L,2);HB:=LLV(H,2);LB:=LLV(L,2);B1:=IF(DT>1 AND ((H>=REF(H,1) AND L<=REF(L,1)) OR (H<=REF(GB,1) AND L>=REF(DB,1))),1,0);B2:=IF(GT>1 AND ((H>=REF(H,1) AND L>=REF(L,1)) OR (H<=REF(HB,1) AND L>=REF(LB,1))),1,0);S1:=SUM(B1,DT);S2:=SUM(B2,GT);C1:=DT-S1;C2:=GT-S2;A1:=IF(S1>0,C1>2,DT>3);A2:=IF(S2>0,C2>2,GT>3);L1:DRAWLINE(DT=0 AND A2,L,GT=0 AND A1, H,0),COLORRED,DOTLINE;L2:=DRAWLINE(GT=0 AND A1,H,DT=0 AND A2, L,0);HT0:=BARSLAST(L1!=DRAWNULL);LT0:=BARSLAST(L2!=DRAWNULL);X:=MIN(CONST(HT0),CONST(LT0));HT:=IF(CURRBARSCOUNT<=CONST(X)+1,HT0,BARSLAST(L1=L2 AND GT=0));HT1:=SUMBARS(HT=0,2);HT2:=SUMBARS(HT=0,3);BT:=IF(CURRBARSCOUNT<=CONST(X)+1,LT0,BARSLAST(L1=L2 AND DT=0));BT1:=SUMBARS(BT=0,2);BT2:=SUMBARS(BT=0,3);H1:=CONST(REF(H,HT));H2:=CONST(REF(H,HT1-1));H3:=CONST(REF(H,HT2-1)); LD2:=CONST(REF(L,BT1-1));LD3:=CONST(REF(L,BT2-1));B10:=H>=REF(H,1) AND L<=REF(L,1);B20:=H<=REF(H,1) AND L>=REF(L,1);HH:=LLV(H,2);LL:=LLV(L,2);HH1:=IF(B10 OR B20,HH,H);LL1:=IF(B10 OR B20,LL,L);T:=BARSLAST(H<REF(HH1,1) AND L<REF(LL1,1));TT:=BARSLAST(H>REF(HH1,1) AND L>REF(LL1,1));TJ:=EVERY(B10 OR B20,T) AND T>0;TJ1:=EVERY(B10 OR B20,TT) AND TT>0;A:=BARSLASTCOUNT((B10 OR B20));A3:=EVERY(A=0,3);A4:=EVERY(A=0,2) AND REF(A>0,2);A6:=COUNT(TT=0,T+1)=1;A7:=COUNT(T=0,T+1)=1;XG1:=REF(H,1)<REF(H,2) AND REF(L,1)<REF(L,2) AND L>REF(L,1) AND H>REF(H,1) AND A3;XG2:=REF(T=0 AND A=0,TT+1) AND A>0 AND TJ1 AND HH1>REF(H,T) AND LL1>REF(L,T) AND A6 AND A7;XG3:=REF(TJ AND A>0,TT+1) AND A>0 AND TJ1 AND HH1>REF(HH1,TT+1) AND LL1>REF(LL1,TT+1) AND A6 AND A7;XG4:=A=0 AND TT=0 AND REF(A>0,1) AND REF(TJ,1) AND H>REF(HH1,1) AND L>REF(LL1,1);XG5:=REF(H,1)<REF(HH1,2) AND REF(L,1)<REF(LL1,2) AND H>REF(H,1) AND L>REF(L,1) AND A4 AND A6 AND A7;TS:=BARSLAST(CROSS(T=0,0.5));VAR1:=CURRBARSCOUNT<CONST(HT0);QF1:=BACKSET(XG1,TS+1);QF2:=BACKSET(XG2,TS+1);QF3:=BACKSET(XG3,TS+1);QF4:=BACKSET(XG4,TS+1);QF5:=BACKSET(XG5,TS+1);VAR2:=QF1 OR QF2 OR QF3 OR QF4 OR QF5;DLT:=IF(VAR2 AND VAR1,L,9999);LTT:=BARSLAST(DLT=LLV(DLT,HT0+1));EXT2:DRAWLINE(CURRBARSCOUNT>=CONST(HT0)+1 AND GT=0 AND A1,H,CURRBARSCOUNT>=CONST(HT0)+1 AND DT=0 AND A2,L,0),COLORYELLOW,DOTLINE;EXT3:DRAWLINE(CURRBARSCOUNT=CONST(HT0)+1,H,CURRBARSCOUNT<CONST(HT0) AND A2 AND LTT=0 AND L=DLT,L,0),COLORYELLOW,DOTLINE;CT:=BARSLAST(EXT3!=DRAWNULL AND EXT2=DRAWNULL);CB:=CONST(REF(EXT3,CT));CT1:=BARSLAST(L2=L1 AND DT=0 AND A2);CT2:=SUMBARS(CT1=0,2);CT3:=SUMBARS(CT1=0,3);F1:=BARSLAST(L1=L2 AND GT=0 AND A1);F2:=REF(F1,CT1);F3:=REF(F1,CT2-1);天差:IF(F2<F3,F3-F2,0),NODRAW,COLORBROWN;SM:=BARSLAST(CROSS(0,MACD.MACD));ML:=LLV(MACD.MACD,SM+1);M2:=REF(ML,CT1);M3:=REF(ML,CT2-1);IL:=LLV(MACD.DIF,SM+1);I2:=REF(IL,CT1);I3:=REF(IL,CT2-1);DEL:=LLV(MACD.DEA,SM+1);DE2:=REF(DEL,CT1);DE3:=REF(DEL,CT2-1);K2:=REF(L,CT1)<REF(L,CT2-1) AND M2>M3;K3:=REF(L,CT1)<REF(L,CT2-1) AND I2>I3;K4:=REF(L,CT1)<REF(L,CT2-1) AND DE2>DE3;背离指数:K2+K3+K4+天差 NODRAW,COLORLIRED;XGW:=CT<3 AND EVERY(EXT2=DRAWNULL,HT0) AND REF(EXT3,CT)>REF(L,CT1) AND REF(L,CT1)<REF(L,CT2-1);XGZ:=H1>H2 AND V>REF(V,CT);XGY:=背离指数>0;TJA:=CONST(H1)>CONST(H2) AND CONST(CT)>0 AND CONST(REF(L,CT))>CONST(REF(L,CT1)) AND CONST(REF(L,CT1))<CONST(REF(L,CT2-1));止损价:DRAWLINE(TJA AND CURRBARSCOUNT=CONST(CT)+1,L,ISLASTBAR AND BARSLAST(XGW AND XGZ AND C=HHV(MAX(C,O),CT+1))>0,REF(L,CT),0),COLORCYAN;高:DRAWLINE(TJA AND CURRBARSCOUNT=CONST(CT1)+1,CONST(H1),ISLASTBAR,CONST(H1),0),COLORMAGENTA;底:DRAWLINE(TJA AND CURRBARSCOUNT=CONST(CT1)+1,CONST(REF(L,CT1)),ISLASTBAR,CONST(REF(L,CT1)),0),COLORMAGENTA;F618:=(高-底)*0.618+底;F050:=(高-底)*0.5+底;F382:=(高-底)*0.382+底;H618:DRAWLINE(TJA AND CURRBARSCOUNT=CONST(CT1)+1,F618,ISLASTBAR,F618,0),COLORLIRED,DOTLINE;H050:DRAWLINE(TJA AND CURRBARSCOUNT=CONST(CT1)+1,F050,ISLASTBAR,F050,0),COLORYELLOW,DOTLINE;H382:DRAWLINE(TJA AND CURRBARSCOUNT=CONST(CT1)+1,F382,ISLASTBAR,F382,0),COLORGREEN,DOTLINE;STICKLINE(TJA AND CURRBARSCOUNT=CONST(CT1)+1,高,底,0,0),COLORMAGENTA;FX:=XG1 OR XG2 OR XG3 OR XG4 OR XG5;XGW1:=REF(L,CT)>=F382 AND FX;XGSS:=XGZ AND TJA AND XGY AND XGW1;XGA:=COUNT(XGSS,CT+1)=1 AND XGSS;XGWW:=CT<3 AND EVERY(EXT2=DRAWNULL,HT0) AND REF(EXT3,CT)>REF(L,CT1) AND REF(L,CT1)<REF(L,CT2-1);XGZZ:=H1>H2 AND V>REF(V,CT);XGX:=XGWW AND XGZZ AND C=HHV(MAX(C,O),CT+1)AND XGY;XGB:=COUNT(XGX,CT+1)=1 AND XGX;XG:=XGA AND XGB;STICKLINE(XG,L,H,0,0),COLORRED;STICKLINE(XG,C,O,2,0),COLORYELLOW;STICKLINE(XG,C,O,1,0),COLORRED;STICKLINE(XG,C,O,0.5,0),COLORYELLOW;STICKLINE(XG,C,O,0.02,0),COLORRED;DRAWICON(XG,L*0.98,25);