MACD背离分为三种类型,分别是线背离、柱(幅度)背离、积(面积)背离。
线背离:当股价指数逐波下(上)行,而DIF及DEA不是同步下(上)降,而是逐波上(下);
线背离用自带的MACD软件就能分辨
今天分享给大家的是自用指标,是增强的通达信MACD背离提示副图指标,包括柱(幅度)背离预警及提示,积(面积)背离预警及提示。
红色是底背离,在0轴下;绿色是顶背离,在0轴上
一、通达信【MACD柱面背离图解】幅图源码分享(请先把源码复制到WORD文档排序,再从WORD文档中复制源码)
DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA : EMA(DIFF,9);
MACD : 2*(DIFF-DEA), COLORSTICK;
HRULER:=CONST( IF(ISLASTBAR,HHV(MAX(ABS(DIFF),ABS(DEA)),90),0)),NODRAW;
{以下计算红绿柱的面积,当绿柱时,红柱面积为0,反之同理}
绿柱面积:=IF(MACD<0,SUM(MACD,BARSLAST(MACD>0)),0);
红柱面积:=IF(MACD>0,SUM(MACD,BARSLAST(MACD<0)),0);
本次最低绿柱:=IF(MACD<0,LLV(MACD,BARSLAST(MACD>0)),0);
本次最高红柱:=IF(MACD>0,HHV(MACD,BARSLAST(MACD<0)),0);
{以下计算红柱期间的最高价(当绿柱时,本次最高价无效,是随机值)
计算绿柱期间的最低价(当红柱时,本次最低价无效,是随机值
}
本次最低价:=LLV(L,BARSLAST(MACD>0)),NODRAW;
本次最高价:=HHV(H,BARSLAST(MACD<0));
{绿柱时,统计绿柱的累计数量,红柱时,为0}
X1:=IF (MACD<0,BARSLAST(CROSS(DIFF,DEA)),0),NODRAW;
{绿柱时,表示前一波绿柱的累计面积;
首根红柱时,表示最近的绿柱面积;
其他红柱时,为0
前次最低价,同理;
}
前次绿柱面积:=REF(绿柱面积,X1 1),NODRAW;
前次最低价:=REF(本次最低价,X1 1),NODRAW;
前次最低绿柱:=REF(本次最低绿柱,X1 1);
Y1:=IF((绿柱面积<0 AND ABS(绿柱面积)<ABS(前次绿柱面积)
AND 本次最低价<前次最低价 ),1,0),NODRAW;
Y11:=IF((绿柱面积<0 AND ABS(本次最低绿柱)<ABS(前次最低绿柱)
AND 本次最低价<前次最低价 ),1,0),NODRAW;
{下面语句在公式中没有用到}
RS1:=MACD<0 AND REF(MACD,1)<0 AND 本次最低价<前次最低价
AND ABS(绿柱面积)<ABS(前次绿柱面积) AND ABS(MACD)<ABS(REF(MACD,1));
{UP3为1,表示绿柱,且连续第三根缩短}
UP3:=RS1 AND UPNDAY(MACD,3);
STEP1:=IF(UP3,(MACD-REF(MACD,1))*0.45 (MACD-REF(MACD,2))*0.17 (MACD-REF(MACD,3))*0.07,0);
N1:=IF(UP3,ABS(MACD)/ABS(STEP1),0),NODRAW;
补充绿柱面积:=IF(UP3,IF(N1>1,(N1-1)*MACD/2,0),0);
Y1补:=IF((绿柱面积<0 AND ABS(绿柱面积 补充绿柱面积)<ABS(前次绿柱面积)
AND 本次最低价<前次最低价 ),1,0);
底积将背:= IF( UP3,Y1补,0),NODRAW;
底柱将背:= IF(UP3,Y11,0),NODRAW;
底积背离:= IF (CROSS(DIFF,DEA),REF(Y1,1),0),NODRAW;
底柱背离:= IF(CROSS(DIFF,DEA),REF(Y11,1),0),NODRAW;
底背离:底积背离 AND 底柱背离,NODRAW;
底背程度:=IF(底积将背 OR 底积背离,ABS(前次绿柱面积)/ABS(绿柱面积 补充绿柱面积)*前次最低价/本次最低价,0),NODRAW;
底柱程度:=IF(底柱将背 OR 底柱背离,ABS(前次最低绿柱)/ABS(本次最低绿柱)*前次最低价/本次最低价,0),NODRAW;
PT:=MIN(DIFF,DEA)-HRULER/20;
PT1:=MAX(DIFF,DEA) HRULER/20;
{
DRAWTEXT(底积将背,0.3,'底积将背'),COLOR00FFFF;
}
DRAWBAND(DIFF,RGB(200,50,55),DEA,RGB(50,100,10));
STICKLINE(底积将背,PT,PT-MIN(底背程度,5)*HRULER/(4*5),2,0),COLORD33AE9;
DRAWICON(底积将背,PT-MIN(底背程度,5)*HRULER/(4*5)-HRULER/20,38),COLORYELLOW;
STICKLINE(底柱将背,PT1,PT1 MIN(底柱程度,5)*HRULER/(4*5),2,0),COLORD33AE9;
DRAWICON(底柱将背,PT1 MIN(底柱程度,5)*HRULER/(4*5) HRULER/10,1),COLORYELLOW;
DRAWTEXT(底柱背离,PT1 HRULER/8,' 柱背'),COLOR00FFFF;
STICKLINE(底柱背离,PT1,PT1 MIN(底柱程度,5)*HRULER/(4*5),3,0),COLOR0000FF;
DRAWICON(底柱背离,PT1 MIN(底柱程度,5)*HRULER/(4*5) HRULER/10,34),COLORYELLOW;
DRAWTEXT(底积背离,PT-HRULER/8,' 积背'),COLOR00FFFF;
STICKLINE(底积背离,PT,PT-MIN(底背程度,5)*HRULER/(4*5),3,0),COLOR0000FF;
DRAWICON(底积背离,PT-MIN(底背程度,5)*HRULER/(4*5)-HRULER/20,23),COLORYELLOW;
D_SCORE:=IF(底积背离 AND 底柱背离,100,
IF(底积背离 OR 底柱背离,80,
IF(底积将背 AND 底柱将背,90,
IF(底积将背 OR 底柱将背,70,
0))));
DT_SOCRE:=IF(D_SCORE>0,D_SCORE,
IF(REF(D_SCORE,1)>0,REF(D_SCORE,1)*0.8,
IF(REF(D_SCORE,2)>0,REF(D_SCORE,2)*0.6,
IF(REF(D_SCORE,3)>0,REF(D_SCORE,3)*0.4,
IF(REF(D_SCORE,4)>0,REF(D_SCORE,4)*0.2,0) ) ) )),NODRAW;
X2:=IF (MACD>0,BARSLAST(CROSS(DEA,DIFF)),0);
前次红柱面积:=REF(红柱面积,X2 1);
前次最高价:=REF(本次最高价,X2 1);
前次最高红柱:=REF(本次最高红柱,X2 1);
Y2:=IF((红柱面积>0 AND 红柱面积<前次红柱面积 AND 本次最高价>前次最高价 ),1,0);
Y22:=IF((红柱面积>0 AND ABS(本次最高红柱)<ABS(前次最高红柱)
AND 本次最高价>前次最高价 ),1,0),NODRAW;
RS2:= MACD>0 AND REF(MACD,1)>0 AND C>前次最高价 AND ABS(红柱面积)<ABS(前次红柱面积) AND ABS(MACD)<ABS(REF(MACD,1));
{DOWN3为1,表示红柱,且连续第三根缩短}
DOWN3:=RS2 AND DOWNNDAY(MACD,3);
STEP2:=IF(DOWN3,(MACD-REF(MACD,1))*0.45 (MACD-REF(MACD,2))*0.17 (MACD-REF(MACD,3))*0.07,0);
N2:=IF(DOWN3,ABS(MACD)/ABS(STEP2),0),NODRAW;
补充红柱面积:=IF(DOWN3,IF(N2>1,(N2-1)*MACD/2,0),0);
Y2补:=IF((红柱面积>0 AND ABS(红柱面积 补充红柱面积)<ABS(前次红柱面积)
AND 本次最高价>前次最高价 ),1,0);
顶积将背:= IF( DOWN3,Y2补,0),NODRAW;
顶柱将背:= IF(DOWN3,Y22,0),NODRAW;
顶积背离:= IF (CROSS(DEA,DIFF),REF(Y2,1),0),NODRAW;
顶柱背离:= IF(CROSS(DEA,DIFF),REF(Y22,1),0),NODRAW;
顶背离: 顶积背离 AND 顶柱背离,NODRAW;
顶背程度:=IF(顶积将背 OR 顶积背离,ABS(前次红柱面积)/ABS(红柱面积 补充红柱面积)*本次最高价/前次最高价,0),NODRAW;
顶柱程度:=IF(顶柱将背 OR 顶柱背离,ABS(前次最高红柱)/ABS(本次最高红柱)*本次最高价/前次最高价,0),NODRAW;
{
DRAWICON(顶积背离,0,19),COLOR00FF00;
STICKLINE(顶积背离,0,-0.3,2,0),COLOR00FF00;
DRAWTEXT(顶积背离,-0.3,'顶积背离'),COLORFF0000;
}
STICKLINE(顶积将背,PT,PT-MIN(顶背程度,5)*HRULER/(4*5),2,0),COLORFFFF00;
DRAWICON(顶积将背,PT-MIN(顶背程度,5)*HRULER/(4*5)-HRULER/20,39),COLORYELLOW;
STICKLINE(顶柱将背,PT1,PT1 MIN(顶柱程度,5)*HRULER/(4*5),2,0),COLORFFFF00;
DRAWICON(顶柱将背,PT1 MIN(顶柱程度,5)*HRULER/(4*5) HRULER/10,2),COLORYELLOW;
DRAWTEXT(顶柱背离,PT1 HRULER/8,' 柱背'),COLOR00FFFF;
STICKLINE(顶柱背离,PT1,PT1 MIN(顶柱程度,5)*HRULER/(4*5),3,0),COLOR00FF00;
DRAWICON(顶柱背离,PT1 MIN(顶柱程度,5)*HRULER/(4*5) HRULER/10,35),COLORYELLOW;
DRAWTEXT(顶积背离,PT-HRULER/8,' 积背'),COLOR00FFFF;
STICKLINE(顶积背离,PT,PT-MIN(顶背程度,5)*HRULER/(4*5),3,0),COLOR00FF00;
DRAWICON(顶积背离,PT-MIN(顶背程度,5)*HRULER/(4*5)-HRULER/20,45),COLORYELLOW;
NOTEXTSDIFF:DIFF,COLORWHITE;
NOTEXTSDEA:DEA,COLORYELLOW;
NOTEXTMACDDRAW:MACD, COLORSTICK;
发文是给喜欢研究和喜欢MACD的朋友,看似简单的画线,其实很有难度。尽管股市不是一个技术指标就能搞定的,但多参考一些技术指标,没有坏处。说不定哪一天你就成功了,贵在坚持!!!!
如果文章对你有帮助,“点赞、收藏、关注”是对八戒最大的支持!