去评论
彩虹桥投资充电站

通达信公式指标源码MACD三背离选股副图指标

风云18171265739
2023/04/21 14:52:03
{MACD三背离}

MACD2:=2*(MACD.DIF-MACD.DEA);

STICKLINE(MACD2>=0 AND MACD2>REF(MACD2,1),0,MACD2,1.2,0),COLOR0000A5;

STICKLINE(MACD2>=0 AND MACD2<REF(MACD2,1),0,MACD2,1.2,0),COLORAA7800;

STICKLINE(MACD2<0 AND MACD2<REF(MACD2,1),0,MACD2,1.2,0),COLOR00A500;

STICKLINE(MACD2<0 AND MACD2>REF(MACD2,1),0,MACD2,1.2,0),COLORA500A5;

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

DEA:EMA(DIF,9);

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

{MACD日线二次金叉}

JCCOUNT:=COUNT(CROSS(DIF,DEA),BARSLAST(DEA>=0));

二次金叉:=CROSS(DIF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;

DRAWTEXT(二次金叉,DEA*1.25,'零下二金'),COLORWHITE;

{MACD日线底背离}

A1:=BARSLAST(REF(CROSS(DIF,DEA),1));

底背离:=REF(CLOSE,A1+1)>CLOSE AND DIF>REF(DIF,A1+1) AND CROSS(DIF,DEA);

DRAWTEXT(底背离,DIF*0.5,'日底背'),COLORRED;

{日底背画线:DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORRED,DOTLINE;}

{MACD日线顶背离}

A2:=BARSLAST(REF(CROSS(DEA,DIF),1));

顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIF,A2+1)>DIF AND CROSS(DEA,DIF);

DRAWTEXT(顶背离,DIF*1.12,'日顶背'),COLORGREEN;

{日顶背画线:DRAWLINE(A2=0,DEA,顶背离,DEA,0),COLORGREEN,DOTLINE;}

{MACD_KDJ的金叉共振}

{DIF:EMA(CLOSE,12)-EMA(CLOSE,26);DEA:EMA(DIF,9);}

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;

M&K金共:=CROSS(DIF,DEA) AND CROSS(K,D) AND CROSS(J,D);

DRAWTEXT(M&K金共,DEA*1.12,'金叉共振'),COLORYELLOW;

{MACD柱背离}

MACD高:=HHV(MACD,5);

C1:=BARSLAST(REF(CROSS(DEA,DIF),1));

E:=REF(C,C1+1)>C AND DEA>0 AND REF(MACD高,C1+1)<MACD高 AND CROSS(DEA,DIF) ;

DRAWTEXT(E>0,-0.5,'柱顶背'),COLORCYAN;

F:=REF(C,A1+1)>C AND DEA<0 AND REF(MACD高,A1+1)<MACD高 AND CROSS(DIF,DEA);

DRAWTEXT(F>0,0.5,'柱底背'),COLORLIRED;

{MACD积背离}

JC:= DEA-DIF;

绿柱面积:=IF(MACD<0,SUM(MACD,BARSLAST(JC<0)),0);

红柱面积:=IF(MACD>0,SUM(MACD,BARSLAST(JC>0)),0);

本次最低价:=LLV(L,BARSLAST(JC<0));

本次最高价:=HHV(H,BARSLAST(JC>0));

X1:=IF (MACD<0,BARSLAST(CROSS(DIF,DEA)),0);

前次绿柱面积:=REF(绿柱面积,X1+1);

前次最低价:=REF(本次最低价,X1+1);

Y1:=IF((绿柱面积<0 AND ABS(绿柱面积)<ABS(前次绿柱面积) AND 本次最低价<前次最低价 ),1,0);

RS1:= MACD<0 AND REF(MACD,1)<0 AND C<前次最低价

AND ABS(绿柱面积)<ABS(前次绿柱面积) AND ABS(MACD)<ABS(REF(MACD,1));

底背驰:= IF (CROSS(DIF,DEA),REF(Y1,1),0);

DRAWTEXT(底背驰,DEA*0.8,'积底背'),COLORFF80FF;

X2:=IF (MACD>0,BARSLAST(CROSS(DEA,DIF)),0);

前次红柱面积:=REF(红柱面积,X2+1);

前次最高价:=REF(本次最高价,X2+1);

Y2:=IF((红柱面积>0 AND 红柱面积<前次红柱面积 AND 本次最高价>前次最高价 ),1,0);

RS2:= MACD>0 AND REF(MACD,1)>0 AND C>前次最高价 AND ABS(红柱面积)<ABS(前次红柱面积) AND ABS(MACD)<ABS(REF(MACD,1));

顶背驰:= IF (CROSS(DEA,DIF),REF(Y2,1),0);

DRAWTEXT(顶背驰,DEA*0.8,'积顶背'),COLORCYAN;

{两个同时背离选股}

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

DEA:=EMA(DIF,9);

MACD:=(DIF-DEA)*2;

A1:=BARSLAST(REF(CROSS(DIF,DEA),1));

底背离:=REF(CLOSE,A1+1)>CLOSE AND DIF>REF(DIF,A1+1) AND CROSS(DIF,DEA);

MACD高:=HHV(MACD,5);

F:=REF(C,A1+1)>C AND DEA<0 AND REF(MACD高,A1+1)<MACD高 AND CROSS(DIF,DEA);

柱底背:=F>0;

JC:= DEA-DIF;

绿柱面积:=IF(MACD<0,SUM(MACD,BARSLAST(JC<0)),0);

红柱面积:=IF(MACD>0,SUM(MACD,BARSLAST(JC>0)),0);

本次最低价:=LLV(L,BARSLAST(JC<0));

本次最高价:=HHV(H,BARSLAST(JC>0));

X1:=IF (MACD<0,BARSLAST(CROSS(DIF,DEA)),0);

前次绿柱面积:=REF(绿柱面积,X1+1);

前次最低价:=REF(本次最低价,X1+1);

Y1:=IF((绿柱面积<0 AND ABS(绿柱面积)<ABS(前次绿柱面积) AND 本次最低价<前次最低价 ),1,0);

RS1:= MACD<0 AND REF(MACD,1)<0 AND C<前次最低价

AND ABS(绿柱面积)<ABS(前次绿柱面积) AND ABS(MACD)<ABS(REF(MACD,1));

积底背:= IF (CROSS(DIF,DEA),REF(Y1,1),0);

AA1:=底背离 AND 柱底背;

AA2:=底背离 AND 积底背;

AA3:=柱底背 AND 积底背;

XG:AA1 OR AA2 OR AA3;

{三个同时背离选股}

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

DEA:=EMA(DIF,9);

MACD:=(DIF-DEA)*2;

A1:=BARSLAST(REF(CROSS(DIF,DEA),1));

底背离:=REF(CLOSE,A1+1)>CLOSE AND DIF>REF(DIF,A1+1) AND CROSS(DIF,DEA);

MACD高:=HHV(MACD,5);

F:=REF(C,A1+1)>C AND DEA<0 AND REF(MACD高,A1+1)<MACD高 AND CROSS(DIF,DEA);

柱底背:=F>0;

JC:= DEA-DIF;

绿柱面积:=IF(MACD<0,SUM(MACD,BARSLAST(JC<0)),0);

红柱面积:=IF(MACD>0,SUM(MACD,BARSLAST(JC>0)),0);

本次最低价:=LLV(L,BARSLAST(JC<0));

本次最高价:=HHV(H,BARSLAST(JC>0));

X1:=IF (MACD<0,BARSLAST(CROSS(DIF,DEA)),0);

前次绿柱面积:=REF(绿柱面积,X1+1);

前次最低价:=REF(本次最低价,X1+1);

Y1:=IF((绿柱面积<0 AND ABS(绿柱面积)<ABS(前次绿柱面积) AND 本次最低价<前次最低价 ),1,0);

RS1:= MACD<0 AND REF(MACD,1)<0 AND C<前次最低价

AND ABS(绿柱面积)<ABS(前次绿柱面积) AND ABS(MACD)<ABS(REF(MACD,1));

积底背:= IF (CROSS(DIF,DEA),REF(Y1,1),0);

三背离:底背离 AND 柱底背 AND 积底背;

风险提示:本指标公式仅作为知识分享,不构成任何投资建议,投资有风险,交易需谨慎。

  • 鍏嶈垂鎸囨爣鍒嗕韩銆愮簿鍝佹寚鏍囥戞捣楸间箣閲戜紭鍖栫増鈥斺旂ǔ瀹氬彲闈犵殑
  • 鍏嶈垂鎸囨爣鍒嗕韩閫氳揪淇°愭父璧勯噾榫欑獊鐮淬戜富鍥炬寚鏍 锛屽姪浣犺偂
  • 鍏嶈垂鎸囨爣鍒嗕韩閫氳揪淇°愰緳鑸熸姄榫欍 鎵嬫満鐢佃剳閫氱敤鍓夋寚鏍
  • 鍏嶈垂鎸囨爣鍒嗕韩閫氳揪淇♀滄瀬闄愭礂鐩樷濆壇鍥炬寚鏍囬夎偂鍏紡--鍚姩
  • 鍏嶈垂鎸囨爣鍒嗕韩0729|鈥嬧嬧嬧嬮氳揪淇¢珮鑳滅巼銆愮珵浠疯繛鏉挎墦濡
  • 鍏嶈垂鎸囨爣鍒嗕韩鍛ㄦ湯绂忓埄閾佹爲寮鑺辫繘鍑荤増鎸囨爣婧愮爜涓诲浘闄勫浘閫