通达信最强MACD副图公式源码
DIF1:=EMA(CLOSE,24) - EMA(CLOSE,52);
DEA1:=EMA(DIF1,9);
MACD1:=2*(DIF1-DEA1),STICK;
MACD2:=EMA(MACD1,3);
STICKLINE(MACD1>MACD2 AND MACD1>0,0,MACD1,1,0),COLOR000099;
STICKLINE(MACD1>MACD2 AND MACD1<0,0,MACD1,1,0),COLOR009900;
STICKLINE(MACD1<MACD2,0,MACD1,1,0),COLOR666666;
STICKLINE(MACD1>=0 OR MACD1<=0,0,0,50,1),COLOR666666;
DIFF:DIF1,COLOR009900;
DEA:DEA1,COLOR22A6E6;
MACD:MACD1,NODRAW,COLORMAGENTA;
强:IF(DIF1>=DEA1,DIF1,DRAWNULL),COLOR000099,LINETHICK2;
DRAWICON(CROSS(DIF1,DEA1),DIF1+0.05,1);
JCCOUNT:=COUNT(CROSS(DIF1,DEA1),BARSLAST(DEA1>=0));
二次金叉:=CROSS(DIF1,DEA1) AND DEA1<0 AND COUNT(JCCOUNT=2,21)=1;
DRAWTEXT(二次金叉,-DEA1*0.6,'二次金叉'),COLOR00BBBB;
三金叉:=CROSS(DIF1,DEA1) AND DEA1<0 AND COUNT(JCCOUNT=3,28)=1;
DRAWTEXT(三金叉,-DEA1*0.6,'三次金叉'),COLOR00BBBB;
四金叉:=CROSS(DIF1,DEA1) AND DEA1<0 AND COUNT(JCCOUNT=4,28)=1;
DRAWTEXT(四金叉,-DEA1*0.6,'四次金叉'),COLOR555555;
五金叉:=CROSS(DIF1,DEA1) AND DEA1<0 AND COUNT(JCCOUNT=5,33)=1;
DRAWTEXT(五金叉,-DEA1*0.6,'五次金叉'),COLOR555555;
六金叉:=CROSS(DIF1,DEA1) AND DEA1<0 AND COUNT(JCCOUNT=6,33)=1;
DRAWTEXT(六金叉,-DEA1*0.6,'黄金底'),COLOR555555;
DRAWTEXT(六金叉,-DEA1*0.6,'六次金叉'),COLOR555555;
七金叉:=CROSS(DIF1,DEA1) AND DEA1<0 AND COUNT(JCCOUNT=7,33)=1;
DRAWTEXT(七金叉,-DEA1*0.6,'白金底'),COLOR555555;
DRAWTEXT(七金叉,-DEA1*0.6,'七次金叉'),COLOR555555;
八金叉:=CROSS(DIF1,DEA1) AND DEA1<0 AND COUNT(JCCOUNT=8,33)=1;
DRAWTEXT(八金叉,-DEA1*0.6,'钻石底'),COLORMAGENTA;
DRAWTEXT(八金叉,-DEA1*0.6,'八次金叉'),COLOR555555;
九金叉:=CROSS(DIF1,DEA1) AND DEA1<0 AND COUNT(JCCOUNT=9,33)=1;
DRAWTEXT(九金叉,-DEA1*0.6,'金钻底'),COLORRED;
DRAWTEXT(九金叉,-DEA1*0.6,'九次金叉'),COLOR555555;
A1:=BARSLAST(REF(CROSS(DIF1,DEA1),1));
底背离:=REF(CLOSE,A1+1)>CLOSE AND DIF1>REF(DIF1,A1+1) AND CROSS(DIF1,DEA1);
DRAWTEXT(底背离,DIF1*0.8,'底背离'),COLOR555555;
A2:=BARSLAST(REF(CROSS(DEA1,DIF1),1));
顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIF1,A2+1)>DIF1 AND CROSS(DEA1,DIF1);
DRAWTEXT(顶背离,DIF1*0.8,'顶背离'),COLOR555555;
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;
A:=CROSS(DIF1,DEA1) AND CROSS(K,D) AND CROSS(J,D);
DRAWTEXT(A,DEA1*0.5,'M&K共振'),COLOR555555;
C1:=BARSLAST(REF(CROSS('MACD.DEA','MACD.DIF'),1));
JC := DEA1-DIF1;
绿柱面积:=IF(MACD1<0,SUM(MACD1,BARSLAST(JC<0)),0);
红柱面积:=IF(MACD1>0,SUM(MACD1,BARSLAST(JC>0)),0);
本次最低价:=LLV(L,BARSLAST(JC<0));
本次最高价:=HHV(H,BARSLAST(JC>0));
X1:=IF (MACD1<0,BARSLAST(CROSS(DIF1,DEA1)),0);
前次绿柱面积:=REF(绿柱面积,X1+1);
前次最低价:=REF(本次最低价,X1+1);
Y1:=IF((绿柱面积<0 AND ABS(绿柱面积)<ABS(前次绿柱面积)
AND 本次最低价<前次最低价 ),1,0);
RS1:= MACD1<0 AND REF(MACD1,1)<0 AND C<前次最低价
AND ABS(绿柱面积)<ABS(前次绿柱面积) AND ABS(MACD1)<ABS(REF(MACD1,1));
底背驰:= IF (CROSS(DIF1,DEA1),REF(Y1,1),0);
DRAWTEXT(底背驰,-0.7,'积底背'),COLOR666666;
X2:=IF (MACD1>0,BARSLAST(CROSS(DEA1,DIF1)),0);
前次红柱面积:=REF(红柱面积,X2+1);
前次最高价:=REF(本次最高价,X2+1);
Y2:=IF((红柱面积>0 AND 红柱面积<前次红柱面积 AND 本次最高价>前次最高价 ),1,0);
RS2:= MACD1>0 AND REF(MACD1,1)>0 AND C>前次最高价 AND ABS(红柱面积)<ABS(前次红柱面积) AND ABS(MACD1)<ABS(REF(MACD1,1));
顶背驰:= IF (CROSS(DEA1,DIF1),REF(Y2,1),0);
DRAWTEXT(顶背驰,0.3,'顶底背'),COLOR555555;
MACD高:=HHV(MACD1,5);
E:=REF(C,C1+1)>C AND DEA1>0 AND REF(MACD高,C1+1)<MACD高 AND CROSS('MACD.DEA','MACD.DIF') ;
DRAWTEXT(E>0,0.4,'柱顶背'),COLOR555555;
F:=REF(C,A1+1)>C AND DEA1<0 AND REF(MACD高,A1+1)<MACD高 AND CROSS('MACD.DIF','MACD.DEA');
DRAWTEXT(F>0,-0.3,'柱底背'),COLOR666666;
STICKLINE(COUNT(DIF1>DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=7,0,MACD1,1,0),COLORCD7F32;
STICKLINE(COUNT(DIF1>DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=15,0,MACD1,1,0),COLORCD7F32;
STICKLINE(COUNT(DIF1>DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=28,0,MACD1,1,0),COLORCD7F32;
STICKLINE(COUNT(DIF1>DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=36,0,MACD1,1,0),COLORCD7F32;
STICKLINE(COUNT(DIF1>DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=48,0,MACD1,1,0),COLORCD7F32;
STICKLINE(COUNT(DIF1<DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=7,0,MACD1,1,0), COLORE47833;
STICKLINE(COUNT(DIF1<DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=15,0,MACD1,1,0), COLORE47833;
STICKLINE(COUNT(DIF1<DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=28,0,MACD1,1,0) COLORE47833;
STICKLINE(COUNT(DIF1<DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=36,0,MACD1,1,0), COLORE47833;
STICKLINE(COUNT(DIF1<DEA1,BARSLAST(CROSS(DIF1,DEA1))+1)=48,0,MACD1,1,0), COLORE47833;
均MACD:EMA(MACD,5),NODRAW;
A1B:=BARSLAST(REF(CROSS(MACD,均MACD),1));
金叉底背:=REF(CLOSE,A1B+1)>CLOSE AND MACD>REF(MACD,A1B+1) AND CROSS(MACD,均MACD);
DRAWTEXT(金叉底背,REF(MACD,1),'↖__底背'),COLOR008888;
DRAWLINE(A1B=0,均MACD,金叉底背,均MACD,0),COLOR008888,DOTLINE;
A2B:=BARSLAST(REF(CROSS(均MACD,MACD),1));
死叉顶背:=REF(CLOSE,A2B+1)<CLOSE AND REF(MACD,A2B+1)>MACD AND CROSS(均MACD,MACD);
DRAWTEXT(死叉顶背,REF(MACD,1),'↙ ̄顶背'),COLOR009900;
DRAWLINE(A2B=0,均MACD,死叉顶背,均MACD,0),COLOR009900,DOTLINE;