DEA:=EMA(DIF,9);
MACD:=(DIF-DEA)*2,COLORSTICK;
SA:=INTPART(MACD*100+0.5)/100,COLORYELLOW,NODRAW;
红天数:=IF(MACD>0,BARSLAST(CROSS(MACD,0)),DRAWNULL),COLORYELLOW,NODRAW;
绿天数:=IF(MACD<0,BARSLAST(CROSS(0,MACD)),DRAWNULL),COLORCYAN,NODRAW;
W1:STICKLINE(MACD>0,MACD,0,2.5,1),COLORRED;
W2:STICKLINE(MACD<0,MACD,0,2.5,1),COLORCYAN;
VA1:=HHVBARS(MACD,BARSLAST(MACD<0)+1);
VA2:=CROSS(BACKSET(CROSS(0,MACD),REF(VA1,1)+2),0.5);
QG:=DRAWLINE(VA2,MACD,REF(VA2,1),REF(MACD,1),1),COLORGREEN,DOTLINE;
NOTEXT前高A:DRAWLINE(VA2,MACD,ISLASTBAR,REF(MACD,BARSLAST(VA2)),1),COLORWHITE,DOTLINE;
VA3:=LLVBARS(MACD,BARSLAST(MACD>0)+1);
VA4:=CROSS(BACKSET(CROSS(MACD,0),REF(VA3,1)+2),0.5);
QD:=DRAWLINE(VA4,MACD,REF(VA4,1),REF(MACD,1),1),COLORYELLOW,DOTLINE;
NOTEXT前低A:DRAWLINE(VA4,MACD,ISLASTBAR,REF(MACD,BARSLAST(VA4)),1),COLORWHITE,DOTLINE;
W3:STICKLINE(MACD>QG,MACD,QG,1,0),COLORYELLOW;
W4:STICKLINE(MACD<0 AND MACD
基准:=CONST(SUM(VA2,0));
前高:=基准=SUM(VA2,0) AND VA2,COLORCYAN,NODRAW;
前高1:=基准-1=SUM(VA2,0) AND VA2,COLORYELLOW,NODRAW;
前高2:=基准-2=SUM(VA2,0) AND VA2,COLORWHITE,NODRAW;
前高3:=基准-3=SUM(VA2,0) AND VA2,COLORWHITE,NODRAW;
前高4:=基准-4=SUM(VA2,0) AND VA2,COLORWHITE,NODRAW;
距离G1:=BARSLAST(前高1);
距离G2:=BARSLAST(前高2);
距离G3:=BARSLAST(前高3);
距离G4:=BARSLAST(前高4);
NOTEXTG2:DRAWLINE(前高1,MACD,前高 AND MACD>=REF(MACD,距离G1),MACD,0),COLORYELLOW,LINETHICK2;
NOTEXTG1:DRAWLINE(前高1,MACD,前高 AND MACDNOTEXTG3:DRAWLINE(前高2,MACD,前高1 AND MACD>=REF(MACD,距离G2),MACD,0),COLORYELLOW,LINETHICK2;
NOTEXTG4:DRAWLINE(前高2,MACD,前高1 AND MACDNOTEXTG5:DRAWLINE(前高3,MACD,前高2 AND MACD>=REF(MACD,距离G3),MACD,0),COLORYELLOW,LINETHICK2;
NOTEXTG6:DRAWLINE(前高3,MACD,前高2 AND MACDNOTEXTG7:DRAWLINE(前高4,MACD,前高3 AND MACD>=REF(MACD,距离G4),MACD,0),COLORYELLOW,LINETHICK2;
NOTEXTG8:DRAWLINE(前高4,MACD,前高3 AND MACD
基准2:=CONST(SUM(VA4,0));
前低:=基准2=SUM(VA4,0) AND VA4;
前低1:=基准2-1=SUM(VA4,0) AND VA4;
前低2:=基准2-2=SUM(VA4,0) AND VA4;
前低3:=基准2-3=SUM(VA4,0) AND VA4;
前低4:=基准2-4=SUM(VA4,0) AND VA4;
距离D1:=BARSLAST(前低1);
距离D2:=BARSLAST(前低2);
距离D3:=BARSLAST(前低3);
距离D4:=BARSLAST(前低4);
NOTEXTD1:DRAWLINE(前低1,MACD,前低 AND MACD>=REF(MACD,距离D1),MACD,0),COLORYELLOW,LINETHICK2;
NOTEXTD2:DRAWLINE(前低1,MACD,前低 AND MACDNOTEXTD3:DRAWLINE(前低2,MACD,前低1 AND MACD>=REF(MACD,距离D2),MACD,0),COLORYELLOW,LINETHICK2;
NOTEXTD4:DRAWLINE(前低2,MACD,前低1 AND MACDNOTEXTD5:DRAWLINE(前低3,MACD,前低2 AND MACD>=REF(MACD,距离D3),MACD,0),COLORYELLOW,LINETHICK2;
NOTEXTD6:DRAWLINE(前低3,MACD,前低2 AND MACDNOTEXTD7:DRAWLINE(前低4,MACD,前低3 AND MACD>=REF(MACD,距离D4),MACD,0),COLORYELLOW,LINETHICK2;
NOTEXTD8:DRAWLINE(前低4,MACD,前低3 AND MACD
0,COLORBLUE,LINETHICK2;
DIF0:EMA(CLOSE,12)-EMA(CLOSE,26),LINETHICK2;
DEA0:EMA(DIF0,9),LINETHICK2;
MACD0:"MACD.MACD",NODRAW;
W10:STICKLINE(MACD>0,MACD,0,3,1),COLORRED;
W20:STICKLINE(MACD<0,MACD,0,3,1),COLORCYAN;
VA01:=HHVBARS(MACD,BARSLAST(MACD<0)+1);
VA02:=CROSS(BACKSET(CROSS(0,MACD),REF(VA01,1)+2),0.5);
QG0:=CROSS(BACKSET(CROSS(0,MACD) OR (ISLASTBAR AND MACD>0),REF(VA01,1)+2),0.5);
VA03:=LLVBARS(MACD,BARSLAST(MACD>0)+1);
VA04:=CROSS(BACKSET(CROSS(MACD,0),REF(VA03,1)+2),0.5);
BD:=BARSLAST(FILTERX(CROSS(0,MACD),BARSCOUNT(C)));
前低0:DRAWLINE(VA04,MACD,REF(VA04,1),REF(MACD,1),1),LINETHICK2;
BDTJ:=IF(MACD<0,FILTERX(MACD=LLV(MACD,BARSLAST(MACD>0)),
BARSCOUNT(C)),DRAWNULL);
TSBDTJ:=BARSLAST(BDTJ);
BDZH:=FILTERX(MACD
本低:IF(BD+1>=1,CONST(LLV(MACD,BD+1)),DRAWNULL),LINETHICK2;
BDCL:=CROSS(COUNT(CROSS(MACD>本低/2 AND MACD<0,0.5),TSBDTJ)=1,0.5) AND TSBDTJ>=0;
持仓段:0,COLOR00CFFF;
空仓段:0,COLORFFCCFF;
DRAWTEXT(CROSS(DIF,DEA),DIF-0,'建仓'),COLORRED;
DRAWTEXT(CROSS(DEA,DIF),DIF+0,'空仓'),COLORGREEN;
MACD彩柱:(DIF-DEA)*2,COLORSTICK;
STICKLINE(((MACD彩柱0)),0,MACD彩柱,1,0),LINETHICK2;
STICKLINE(((MACD彩柱>REF(MACD彩柱,1)) AND (MACD彩柱<0)),0,MACD彩柱,1,0),COLORFF00FF,LINETHICK2;
建仓:IF(DIF<0,DIF,0),COLORYELLOW,LINETHICK2;
加仓:IF(DIF<0,0,DIF),COLORRED,LINETHICK2;
白线破仓:IF(DIF
0,COLORBLUE,LINETHICK2;
DRAWICON(CROSS(MACD,0),MACD,1);
DRAWICON(CROSS(DEA0,前低0),DEA0,1);
DRAWICON(CROSS(DEA0,NOTEXT前低A),DEA0,1);
DRAWICON(CROSS(DIF0,0),DIF0,1);
DRAWICON(CROSS(DIF,DEA),DEA,1); {5日上穿10日做记号}
DRAWICON(CROSS(DEA,DIF),DEA,2); {5日下穿10日做记号};