DIFF :=EMA(CLOSE,12) – EMA(CLOSE,26);
DEA :=EMA(DIFF,9);
//DIFF :=EMA(CLOSE,5) – EMA(CLOSE,10);
//DEA :=EMA(DIFF,5);
MACD:=2*(DIFF-DEA);
0,COLORYELLOW;
IF(DIFF>0,DIFF,NULL),COLORRED,NOTEXT,LINETHICK2;
IF(DIFF>0&&DIFF<DEA,DIFF,NULL),COLORYELLOW,NOTEXT,LINETHICK3;
IF(DIFF<0,DIFF,NULL),COLORGREEN,NOTEXT,LINETHICK2;
DRAWCOLORLINE(DIFF>DEA,DIFF,COLORRED,COLORGREEN),LINETHICK1;
//DRAWCOLORLINE(DIFF>DEA,DEA,COLORWHITE,COLORWHITE),LINETHICK1;
STICKLINE(MACD>0 AND MACD>REF(MACD,1),MACD,0,COLORRED,0);
STICKLINE(MACD>0 AND MACD<REF(MACD,1),MACD,0,COLORYELLOW,0);
STICKLINE(MACD<0 AND MACD>REF(MACD,1),MACD,0,COLORGREEN,0);
STICKLINE(MACD<0 AND MACD<REF(MACD,1),MACD,0,COLORBLUE,0);
JC:=CROSS(DIFF,DEA);
SC:=CROSSDOWN(DIFF,DEA);
N1:=BARSLAST(JC)+1;
N2:=BARSLAST(SC)+1;
HH:=VALUEWHEN(CROSSDOWN(DIFF,DEA),HHV(H,N1));//上次MACD红柱期间合约最大值
HH2:=VALUEWHEN(CROSSDOWN(DIFF,DEA),REF(HH,1));//上上次MACD红柱期间合约最大值
MHD:=VALUEWHEN(CROSSDOWN(DIFF,DEA),HHV(MACD,N1));//上次MACD红柱期间MACD最大值
MHD2:=VALUEWHEN(CROSSDOWN(DIFF,DEA),REF(MHD,1));//上上次MACD红柱期间MACD最大值
LL:=VALUEWHEN(CROSS(DIFF,DEA),LLV(L,N2));//上次MACD绿柱期间合约最小值
LL2:=VALUEWHEN(CROSS(DIFF,DEA),REF(LL,1));//上上次MACD绿柱期间合约最小值
MLD:=VALUEWHEN(CROSS(DIFF,DEA),LLV(MACD,N2));//上次MACD绿柱期间MACD最小值
MLD2:=VALUEWHEN(CROSS(DIFF,DEA),REF(MLD,1));//上上次MACD绿柱期间MACD最小值
A:=CROSSDOWN(DIFF,DEA)&&HH>HH2&&MHD<MHD2;//顶背离
B:=CROSS(DIFF,DEA)&&LL<LL2&&MLD>MLD2;//底背离
DRAWTEXT(A,DIFF*1.30,'顶背'),COLORGREEN;
DRAWTEXT(B,DIFF*1.50,'底背'),COLORRED;
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9));
K:=SMA(RSV,9,3),NODRAW;
D:=SMA(K,9,3),NODRAW;
J:=3*K-2*D,NODRAW;
MK金共:=CROSS(DIFF,DEA) AND CROSS(K,D) AND CROSS(J,D);
DRAWTEXT(MK金共,DEA*1.12,'振'),COLORYELLOW;
老师好,帮忙顶背和底背做个公式预警,这共振预警可的话也做个公式预警
(来源:文华财经)