MACD主升浪
2016-9-1 13:55:16点击:
MACD指标说明
MACD指数平滑异同移动平均线为两条长、短的平滑平均线。
其买卖原则为:
1.DIFF、DEA均为正,DIFF向上突破DEA,买入信号参考。
2.DIFF、DEA均为负,DIFF向下跌破DEA,卖出信号参考。
3.DEA线与K线发生背离,行情可能出现反转信号。
4.分析MACD柱状线,由红变绿(正变负),卖出信号参考;由绿变红,买入信号参考。
DIF:EMA(CLOSE,12) - EMA(CLOSE,26),colorwhite;
DEA:EMA(DIF,9),coloryellow;
MACD:=2*(DIF-DEA);
Zero : 0,colorred;
IF (DIF>DEA)
{
IF (DIF<0)STOCK:"建仓"; ELSE STOCK:"加仓";
}
ELSE
{
IF (DIF>0) STOCK:"减仓"; ELSE STOCK:"清仓";
}
DRAWICON(CROSS(DIF,0),DIF-0.02,1);//买点图标
DRAWICON(CROSS(DIF,DEA),DIF-0.02,1);//买点图标
DRAWICON(CROSS(0,DIF),DIF-0.02,2);//卖点图标
DRAWICON(CROSS(DEA,DIF),DIF-0.02,2);//卖点图标
FILLRGN(DIF,DEA,DIF>DEA AND DIF>0,RGB(255,255,0),DIF<DEA AND DIF<0,RGB(255,0,255));//面积图
FILLRGN(DIF,DEA,DIF>DEA AND DIF<0,RGB(255,255,255),DIF<DEA AND DIF>0,RGB(0,255,255));//面积图
DRAWGBK(DIF>0),colorblue;
DRAWGBK(DIF<0),colorblack;
/***************************MACD背离算法***************************************************/
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(DIF,55)-LLV(DIF,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 DIF>REF(DIF,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.18,' 底背离'),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 DIF<REF(DIF,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.18,' 顶背离'),colorgreen;
A0:=DIF<0 AND DEA<0;
A11:=A0>REF(A0,1);
A3:=BARSLAST(A11);
A4:=COUNT(DEA>0 AND DIF >0,A3)=0;
A5:=CROSS(DIF ,DEA);
A6:=BARSLAST(A5);
A7:=REF(A6,A6+1)+A6;
A8:=(DIF+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,DIF*0.95,'★金叉买入'),coloryellow;