使用说明:指数平滑异同移动平均线。
1 dif和dea处于0轴以上时,属于多头市场。
2 dif和dea处于0轴以下时,属于空头市场。
3 柱状线收缩和放大。
4 震荡行情中MACD指标将失真。
DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA : EMA(DIFF,9);coloryellow,LINETHICK1;
MACD=2*(DIFF-DEA);
Zero : 0;
gj:=MAX(C,O);
STICKLINE(MACD>0 AND MACD>=REF(MACD,1),0,MACD,2,0),color0000ff;
STICKLINE(MACD>0 AND MACD<REF(MACD,1),0,MACD,2,0),colorffff00;
STICKLINE(MACD<0 AND MACD>=REF(MACD,1),0,MACD,2,0),colorff00ff;
STICKLINE(MACD<0 AND MACD<REF(MACD,1),0,MACD,2,0),color00ff00;
L4:=LLV(gj,4);
jl:=(HHV(diff,55)-LLV(diff,55))/5;
gt:=dea>REF(dea,1) AND REF(dea,1)<REF(dea,2);
A1:=BARSLAST(REF(gt,1));
底背离:=REF(L4,A1+1)>CLOSE AND diff>REF(diff,A1+1) AND gt;
DRAWLINE(A1=0,DEA,底背离,REF(DEA,A1),0),colorred,LINETHICK2;
DRAWLINE(底背离,DEA,底背离,REF(DEA,A1),0),colorred,LINETHICK2;
DRAWTEXT(底背离,REF(DEA,A1)*1.00,' 底背离'),COLORFF00FF;
H4:=HHV(gj,4);
gt2:=dea<REF(dea,1) AND REF(dea,1)>REF(dea,2);
A2:=BARSLAST(REF(gt2,1));
顶背离:= REF(H4,A2+1)<H4 AND diff<REF(diff,A2+1) AND gt2;
DRAWLINE(A2=0 ,DEA,顶背离,REF(DEA,A2),0),colorgreen,LINETHICK2;
DRAWLINE(顶背离,DEA,顶背离,REF(DEA,A2),0),colorgreen,LINETHICK2;
DRAWTEXT(顶背离,REF(DEA,A2)*1.15,' 顶背离'),colorgreen;
A0:=DIFF<0 AND DEA<0;
A11:=A0>REF(A0,1);
A3:=BARSLAST(A11);
A4:=COUNT(DEA>0 AND DIFF >0,A3)=0;
A5:=CROSS(DIFF ,DEA);
A6:=BARSLAST(A5);
A7:=REF(A6,A6+1)+A6;
A8:=(DIFF+DEA)/2;
A9:=(HIGH+LOW)/2;
A10:=A5 AND A7<A3 AND A4 AND A8>REF(A8,A7) AND A9<REF(A9,A7) AND MACD>0;
DRAWTEXT(A10,DIFF*1.10,'★金叉买入'),colorred;
DIF:EMA(CLOSE,12)-EMA(CLOSE,26),colorred,LINETHICK1;
DEA:EMA(DIF,9),coloryellow,LINETHICK1;
持仓段:=0,COLOR00CFFF;
空仓段:=0,COLORFFCCFF;
MACD:(DIF-DEA)*2,COLORSTICK;
STICKLINE(((MACD<REF(MACD,1)) AND (MACD>0)),0,MACD,1,0),colorliblue,LINETHICK2;
STICKLINE(((MACD>REF(MACD,1)) AND (MACD<0)),0,MACD,1,0),COLORFF00FF,LINETHICK2;
建仓:IF(DIF<0,DIF,0),coloryellow,LINETHICK1;
加仓:IF(DIF<0,0,DIF),colorred,LINETHICK1;
白线破仓:IF(DIF<DEA,DIF,DEA),colorwhite,LINETHICK1;
趋势强弱:IF(DIF>DEA,DEA,DEA),COLORFF937F,LINETHICK1;
AA:=COUNT(CROSS(DIF,DEA),BARSLAST(DEA>=0));
二次金叉:=CROSS(DIF,DEA) AND DEA<0 AND COUNT(AA=2,21)=1;
DRAWTEXT(二次金叉,0.06,' 二次金叉'),coloryellow;
DRAWTEXT(CROSS(DEA,DIFF),DIFF+0.06,'▼死叉'),COLOR00FF00;