百分比:=5;
右数峰序:=2;
MA(C,5);
MA(C,10);
MA(C,20);
MA(C,30);
MA(C,60);
C2:=REF(C,1);
涨停:=IF((C-C2)*100/C2>=(10-0.01*100/C2),1,0);
STICKLINE(涨停,OPEN,CLOSE,-1,0),COLORYELLOW;
STICKLINE(涨停,H,L,0,0),COLORYELLOW;
跌停:=IF((C2-C)*100/C2>=(10-0.01*100/C2),1,0);
STICKLINE(跌停,OPEN,CLOSE,-1,0),COLORBLUE;
STICKLINE(跌停,H,L,0,1),COLORBLUE;
大阳线:=IF((C-C2)*100/C2>=5,1,0)&&IF((C-C2)*100/C2<(10-0.01*100/C2),1,0) OR IF((C-O)*100/O>=5,1,0)&&IF((C-C2)*100/C2<(10-0.01*100/C2),1,0);
STICKLINE(大阳线,OPEN,CLOSE,-1,0),COLORRED;
STICKLINE(大阳线,H,L,0,1),COLORRED;
大阴线:=IF((C2-C)*100/C2>=5,1,0)&&IF((C2-C)*100/C2<(10-0.01*100/C2),1,0) OR IF((O-C)*100/O>=5,1,0)&&IF((C2-C)*100/C2<(10-0.01*100/C2),1,0);
STICKLINE(大阴线,OPEN,CLOSE,-1,0),COLORGREEN;
STICKLINE(大阴线,H,L,0,1),COLORGREEN;
TY:=C;
AA1:=REF(TY,10)=HHV(TY,2*10+1); BB1:=FILTER(AA1,10); C1:=BacKSET(BB1,10+1); HD:=FILTER(C1,10);
AA2:=REF(TY,10)=LLV(TY,2*10+1); B2:=FILTER(AA2,10); CC2:=BACKSET(B2,10+1); LD:=FILTER(CC2,10);
前期高位:REF(H,BArslAST(HD)),COLOR00FF00,POINTDOT,LINETHICK3;
前期低位:REF(L,BARSLAST(LD)),COLORFF00FF,POINTDOT,LINETHICK3;
QA:=REF(H,10)=HHV(H,2*10+1);
QB:=BACKSET(QA,10+1);
QC:=FILTER(QB,10) AND H=HHV(H,10+1);
QD:=BARSLAST(QC);
QE:=IF(QC,CURRBARSCOUNT,0);
QF:=IF(QD,REF(QE,QD),QE);
QG:=CONST(QF);
QH:=REF(QF,QD+1);
QW:=CONST(QH);
DRAWLINE(CURRBARSCOUNT=QW,H,CURRBARSCOUNT=QG,H,1),COLOR007FFF;
DRAWLINE(CURRBARSCOUNT=QW,H,ISLASTBAR,REF(H,QW-1),1),COLOR0099FF,POINTDOT;
DRAWLINE(CURRBARSCOUNT=QG,H,ISLASTBAR,REF(H,QG-1),1),COLOR0099FF,POINTDOT;
QM:=INTPART(3*8/5);
QR:=REF(H,QM)=HHV(H,2*QM+1);
QT:=FILTER(QR,QM);
QY:=BACKSET(QT,QM+1);
QU:=FILTER(QY,QM);
QI:=BACKSET(ISLASTBAR,BARSLAST(QU)+1);
QP:=QI>REF(QI,1);
DRAWLINE(QU,H,QP,H,1),COLORE47833;
QA1:=REF(L,8)=LLV(L,2*8+1);
QB1:=BACKSET(QA1,8+1);
QC1:=FILTER(QB1,8) AND L=LLV(L,8+1);
QD1:=BARSLAST(QC1);
QE1:=IF(QC1,CURRBARSCOUNT,0);
QF1:=IF(QD1,REF(L,QD1),L);
QG1:=IF(QD1,REF(QE1,QD1),QE1);
QH1:=CONST(QG1);
QW1:=REF(QF1,QD1+1);
QM1:=REF(QG1,QD1+1);
QR1:=CONST(QM1);
DRAWLINE(CURRBARSCOUNT=QR1,L,CURRBARSCOUNT=QH1,L,1),COLOR007FFF;
DRAWLINE(CURRBARSCOUNT=QH1,L,ISLASTBAR,REF(L,QH1-1),1),COLORWHITE,POINTDOT;
DRAWLINE(CURRBARSCOUNT=QR1,L,ISLASTBAR,REF(L,QR1-1),1),COLORWHITE,POINTDOT;
QT1:=REF(L,QM)=LLV(L,2*QM+1);
QY1:=FILTER(QT1,QM);
QU1:=BACKSET(QY1,QM+1);
QI1:=FILTER(QU1,QM);
QP1:=BACKSET(ISLASTBAR,BARSLAST(QI1)+1);
QJ1:=QP1>REF(QP1,1);
DRAWLINE(QI1,L,QJ1,L,1),COLORE47833;
波谷值: CONST(TROUGH(2,百分比,1)),NODRAW;{前M个zig转向波谷值}
波谷距离:= 1+CONST(TROUGHBARS(2,百分比,1)),NODRAW;{前M个ZIG转向波谷到当前距离}
{例如:TROUGH(2,5,2)表示%5最低价ZIG转向的前2个波谷到当前的周期数};
波峰值:= CONST(PEAK(1,百分比,右数峰序));
{例如:PEAK(1,5,1)表示%5最高价ZIG转向的上一个波峰的数值}
XG:= Abs(波峰值-波谷值)<=0.02 {AND BARSCOUNT(V)>60};
波峰距离:= 1+CONST(PEAKBARS(1,百分比,右数峰序)),NODRAW;
{PEAKBARS(K,N,M)表示之字转向ZIG(K,N)的前M个波峰到当前的周期数,M必须大于等于1}
距离:=CURRBARSCOUNT;
DRAWLINE(距离=波峰距离 AND XG,波谷值,距离=1,波谷值,1),COLORMAGENTA;
DRAWTEXT(距离=波谷距离 AND XG,L*0.98,' 峰谷线'),COLORYELLOW;
DRAWICON(距离=波峰距离,H*1.01,2);{波峰位置}
DRAWICON(距离=波谷距离,L*0.985,1);{波谷位置}
精准点:=(ABS(H-波谷值)<=0.02 OR ABS(L-波谷值)<=0.02) {AND 距离<=120};
STICKLINE(精准点,波谷值,波谷值,10,1),COLORYELLOW;
DRAWTEXT_FIX(1,0.00,0.00,0,EXTERNSTR(0,2))COLORYELLOW,LINETHICK3;
DRAWTEXT_FIX(1,0.00,0.04,0,EXTERNSTR(0,1))COLORYELLOW,LINETHICK3;
MMA:=CONST(HHV(H,90));
MMB:=CONST(LLV(L,90));
WN:=3;{原码 N:=3;}
WA1:=REF(H,WN)=HHV(H,2*WN+1); WB1:=FILTER(WA1,WN); WC1:=BACKSET(WB1,WN+1); WD1:=FILTER(WC1,WN);{高点}
WA2:=REF(L,WN)=LLV(L,2*WN+1); WB2:=FILTER(WA2,WN); WC2:=BACKSET(WB2,WN+1); WD2:=FILTER(WC2,WN);{低点}
WE1:=(REF(LLV(L,2*WN),1)+REF(HHV(H,2*WN),1))/2;
WE2:=(H+L)/2;{高低点出现在同一k线上时可作取舍}
WH1:=(WD1 AND NOT(WD2 AND WE1>=WE2)) OR ISLASTBAR OR BARSCOUNT(C)=1;
WL1:=(WD2 AND NOT(WD1 AND WE1
WX1:=REF(BARSLAST(WH1),1)+1; WF1:=BACKSET(WH1 AND COUNT(WL1,WX1)>0,LLVBARS(IF(WL1,L,10000),WX1));
WG1:=WF1>REF(WF1,1); WI1:=BACKSET(WG1,2); WLD:=WI1>REF(WI1,1);{过滤后低点}
WL2:=WLD OR ISLASTBAR OR BARSCOUNT(C)=1;
WX2:=REF(BARSLAST(WL2),1)+1; WF2:=BACKSET(WL2 AND COUNT(WH2,WX2)>0,HHVBARS(IF(WH2,H,0),WX2));
WG2:=WF2>REF(WF2,1); WI2:=BACKSET(WG2,2); WHD:=WI2>REF(WI2,1);{过滤后高点}
wr1:=BACKSET(ISLASTBAR,BARSLAST(WHD)+1); WS1:=WR1>REF(WR1,1); {前一高}
WT1:=BACKSET(ISLASTBAR,BARSLAST(WLD)+1); WU1:=WT1>REF(WT1,1); {前一低}
WR2:=BACKSET(WS1,REF(BARSLAST(WHD),1)+2); WS2:=WR2>REF(WR2,1); {前二高}
WT2:=BACKSET(WU1,REF(BARSLAST(WLD),1)+2); WU2:=WT2>REF(WT2,1); {前二低}
WT3:=BACKSET(WU2,REF(BARSLAST(WLD),1)+2); WU3:=WT3>REF(WT3,1); {前三低}
WT4:=BACKSET(WU3,REF(BARSLAST(WLD),1)+2); WU4:=WT4>REF(WT4,1); {前四低}
WR3:=BACKSET(WS2,REF(BARSLAST(WHD),1)+2); WS3:=WR3>REF(WR3,1); {前三高}
WR4:=BACKSET(WS3,REF(BARSLAST(WHD),1)+2); WS4:=WR4>REF(WR4,1); {前四高};
压力1:=DRAWLINE(WS2,H,WS1,H,1),COLOR008888; {★压力1:}
支撑1:=DRAWLINE(WU2,L,WU1,L,1),COLOR008888;{★支撑1:}
压力2:=DRAWLINE(WS3,H,WS2,H,1),COLOR888000; {★压力2:}
支撑2:=DRAWLINE(WU3,L,WU2,L,1),COLOR888000;{★支撑2:}
压力3:=DRAWLINE(WS4,H,WS3,H,1),COLOR0000CC;{★压力3:}
支撑3:=DRAWLINE(WU4,L,WU3,L,1),COLOR0000CC;{★支撑3:};
BSC:=CONST(MAX(BARSLAST(WS4),BARSLAST(WU4))*3),NODRAW;
IF(BETWEEN(压力1,MMA,MMB),压力1,DRAWNULL),COLOR008888,LINETHICK1;
IF(BETWEEN(支撑1,MMA,MMB),支撑1,DRAWNULL),COLOR008888,LINETHICK1;
IF(BETWEEN(压力2,MMA,MMB),压力2,DRAWNULL),COLOR888000,LINETHICK1;
IF(BETWEEN(支撑2,MMA,MMB),支撑2,DRAWNULL),COLOR888000,LINETHICK1;
IF(BETWEEN(压力3,MMA,MMB),压力3,DRAWNULL),COLOR0000CC,LINETHICK1;
IF(BETWEEN(支撑3,MMA,MMB),支撑3,DRAWNULL),COLOR0000CC,LINETHICK1;