DIFF := EMA(CLOSE,12) - EMA(CLOSE,26);//短周期与长周期的收盘价的指数平滑移动平均值做差。
DEA := EMA(DIFF,9);//DIFF的M个周期指数平滑移动平均
MACD:=2*(DIFF-DEA),COLORSTICK;//DIFF减DEA的2倍画柱状线 JC:=CROSS(DIFF,DEA);
SC:=CROSSDOWN(DIFF,DEA); N1:=BARSLAST(JC)+1; N2:=BARSLAST(SC)+1; MA5:=MA(C,5),NODRAW;
HH:=VALUEWHEN(CROSSDOWN(DIFF,DEA),DIFF),NODRAW;//B点DIFF值
HHM:=VALUEWHEN(CROSSDOWN(DIFF,DEA),MA5),NODRAW;//B叉点5均线值 HHC:=VALUEWHEN(CROSSDOWN(DIFF,DEA),C),NODRAW;//B叉点K收盘价 HH2:=REF(HH,N2),NODRAW;//A点DIFF值
HHM2:=REF(HHM,N2),NODRAW;//A点5均线值 HHC2:=REF(HHC,N2),NODRAW;//A点K收盘价 CON:=HH2>HH&&(HHM2 YY:=BACKSET(CON&&SC,REF(HHVBARS(DIFF,N1),N1)+N1+1); //DRAWLINE1(CROSS(YY=1,0.5),DIFF,CROSS(XX=1,0.5),DIFF,0),COLORGREEN;// LL:=VALUEWHEN(CROSS(DIFF,DEA),DIFF),NODRAW;//B点DIFF值 LLM:=VALUEWHEN(CROSS(DIFF,DEA),MA5),NODRAW;//B叉点5均线值 LLC:=VALUEWHEN(CROSS(DIFF,DEA),C),NODRAW;//B叉点K收盘价 LL2:=REF(LL,N1),NODRAW;//A点DIFF值 LLM2:=REF(LLM,N1),NODRAW;//A点5均线值DIFF : EMA(CLOSE,12) - EMA(CLOSE,26); DRAWICON(CROSS(DIFF,DEA),L,4),FONTSIZE60; //上箭头 DRAWICON(CROSSDOWN(DIFF,DEA),H,5),VALIGN2,FONTSIZE60;//下箭头 LLC2:=REF(LLC,N1),NODRAW;//A点K收盘价 COM:=LL2 CC:=BACKSET(COM&&JC,LLVBARS(DIFF,N2)+1); DD:=BACKSET(COM&&JC,REF(LLVBARS(DIFF,N2),N2)+N2+1); //DRAWLINE1(CROSS(DD=1,0.5),DIFF,CROSS(CC=1,0.5),DIFF,0),COLORRED; DRAWTEXT(CROSS(XX=1,0.5),H,' 1'),VALIGN2,COLORWHITE,FONTSIZE16;// DRAWTEXT(CROSS(CC=1,0.5),H,' 2'),VALIGN2,COLORWHITE,FONTSIZE16;