通达信MACD背离的思考与公式副图源码思路

 2023-12-23 22:06:08    通达信指标网  

DIFF:= EMA(CLOSE,12) - EMA(CLOSE,26);

DIF:EMA(CLOSE,12) - EMA(CLOSE,26);

DEA:EMA(DIF,9);

MACD:2*(DIF-DEA),COLORSTICK;

CON1:=TROUGH(2,3,1)<TROUGH(2,3,2); 

CON2:=TROUGHBARS(2,3,1)=1 AND L>REF(L*1.03,1)

AND PEAKBARS(1,3,1)>TROUGHBARS(2,3,1) AND PEAKBARS(1,3,1)<TROUGHBARS(2,3,2);

CON3:=REF(MACD,1)>REF(MACD,TROUGHBARS(2,3,2)) AND HHV(MACD,TROUGHBARS(2,3,2))>0;

CON4:=MACD>REF(MACD,1);

T_REVERSE:=CON1 AND CON2 AND CON3 AND CON4;

{上面是对MACD背离的定义,下面是画线}

FLAG:=BACKSET(T_REVERSE,TROUGHBARS(2,3,2)+1);

FLAG1:=BACKSET(T_REVERSE,2);

FLAG2:=COUNT(T_REVERSE,TROUGHBARS(2,3,2)+1)*T_REVERSE;

FLAG3:=BACKSET(FLAG2=2,TROUGHBARS(2,3,2)+1);


DRAWLINE(CROSS(FLAG,0.5),MACD,FLAG2=1,MACD,0),COLORRED,LINETHICK2;

DRAWLINE(CROSS(FLAG3,0.5),MACD,FLAG2=2,MACD,0),COLORYELLOW,LINETHICK2;


DRAWICON(T_REVERSE,MACD*1.2,1);


以下是选股公式:


DIFF:= EMA(CLOSE,12) - EMA(CLOSE,26);

DIF:=EMA(CLOSE,12) - EMA(CLOSE,26);

DEA:=EMA(DIF,9);

MACD:=2*(DIF-DEA);

CON1:=TROUGH(2,3,1)<TROUGH(2,3,2); 

CON2:=TROUGHBARS(2,3,1)=1 AND L>REF(L*1.03,1)

AND PEAKBARS(1,3,1)>TROUGHBARS(2,3,1) AND PEAKBARS(1,3,1)<TROUGHBARS(2,3,2);

CON3:=REF(MACD,1)>REF(MACD,TROUGHBARS(2,3,2)) AND HHV(MACD,TROUGHBARS(2,3,2))>0;

CON4:=MACD>REF(MACD,1);

T_REVERSE:CON1 AND CON2 AND CON3 AND CON4;

  •  标签:  

原文链接:https://www.tdxzb.com/?id=2096

本文版权:如无特别标注,本站文章均为原创。

相关文章

服务热线

18020657357

微信客服

微信客服