通达信中短MACD金叉与死叉指标公式:
中DIFF:(EMA(CLOSE,12) - EMA(CLOSE,26)),LINETHICK2,COLOR2A2AA5;
中DEA:EMA(中DIFF,9),COLORFFFF00;
DRAWBAND(中DIFF,RGB(155,50,50),中DEA,RGB(0,100,50));
MACD2:(2 * (中DIFF -中DEA)),LINETHICK0,COLORFFFF00;
STICKLINE((MACD2>=0),0,MACD2,1,0),COLORRED;
STICKLINE(((MACD2>=0) AND (MACD2 < REF(MACD2,1))),0,MACD2,1,1),COLORLIBLUE;
STICKLINE((MACD2<0),0,MACD2,1,1),COLORGREEN;
STICKLINE(((MACD2<0) AND (MACD2 > REF(MACD2,1))),0,MACD2,1,0),COLORYELLOW;
DU0:=CROSS(中DIFF,0);
UD0:=CROSS(0,中DIFF);
TDU0:=BARSLAST(DU0);
TUD0:=BARSLAST(UD0);
DU3:=REF(DU0,1);
UD3:=REF(UD0,1);
TDU3:=BARSLAST(DU3);
TUD3:=BARSLAST(UD3);
UDGLINE:=IF((TDU3 < TUD3),REF(HHV(HIGH,2),TDU3),REF(LLV(LOW,2),TUD3));
JDU0:=(((REF(CLOSE,1) <= REF(UDGLINE,1)) AND (CLOSE > UDGLINE)) AND (TDU0 < TUD0));
JUD0:=(((REF(CLOSE,1) >= REF(UDGLINE,1)) AND (CLOSE < UDGLINE)) AND (TUD0 < TDU0));
JDU1:=(JDU0 AND (COUNT(JDU0,TDU0) = 1));
JUD1:=(JUD0 AND (COUNT(JUD0,TUD0) = 1));
JDU2:=(JDU1 AND (REF(BARSLAST(JUD1),1) < REF(BARSLAST(JDU1),1)));
JUD2:=(JUD1 AND (REF(BARSLAST(JUD1),1) > REF(BARSLAST(JDU1),1)));
JDU3:=(JDU1 AND (REF(BARSLAST(JUD1),1) > REF(BARSLAST(JDU1),1)));
JUD3:=(JUD1 AND (REF(BARSLAST(JUD1),1) < REF(BARSLAST(JDU1),1)));
BSLINE:=IF((BARSLAST(JDU2) < BARSLAST(JUD2)),IF(REF(CROSS(0,MACD2),1),LLV(LOW,2),REF(LLV(LOW,2),BARSLAST(REF(CROSS(0,MACD2),1)))),IF(REF(CROSS(MACD2,0),1),HHV(HIGH,2),REF(HHV(HIGH,2),BARSLAST(REF(CROSS(MACD2,0),1)))));
DEFUT:=BARSLAST(CROSS(MACD2,0));
DEFDT:=BARSLAST(CROSS(0,MACD2));
DEFUL:=IF((MACD2 >= 0),HHV(MACD2,(DEFUT + 1)),REF(HHV(MACD2,(DEFUT + 1)),(DEFDT + 1)));
DEFDL:=IF((MACD2 < 0),LLV(MACD2,(DEFDT + 1)),REF(LLV(MACD2,(DEFDT + 1)),(DEFUT + 1)));
DEFU2L:=REF(DEFUL,(DEFUT + 1));
DEFD2L:=REF(DEFDL,(DEFDT + 1));
短DIFF:(EMA(C,3)-EMA(C,10)),LINETHICK2,COLORC0C0C0;
短DEA:EMA(短DIFF,9),LINETHICK2,COLOR33FF33;
IF(短DIFF>=短DEA,短DIFF,DRAWNULL),COLORRED,LINETHICK2;
D1:=EMA(C,3)-EMA(C,8);
D2:=EMA(O,3)-EMA(O,8);
D3:=EMA(H,3)-EMA(H,8);
D4:=EMA(L,3)-EMA(L,8);
DRAWICON(((((LLV(MACD2,4) > 0) AND (MACD2 < REF(MACD2,1))) AND (REF(MACD2,1) > REF(MACD2,2))) AND (REF(MACD2,2) > REF(MACD2,3))),0,12);
DRAWICON(((((HHV(MACD2,4) < 0) AND (MACD2 > REF(MACD2,1))) AND (REF(MACD2,1) < REF(MACD2,2))) AND (REF(MACD2,2) < REF(MACD2,3))),0,23);
DRAWICON(CROSS(中DIFF,D1) AND 中DIFF>0.1 ,0,2);
EE:=CROSS(中DIFF,中DEA) AND MACD2>REF(MACD2,1) AND 短DIFF>=REF(短DIFF,1) AND 中DEA>=REF(中DEA,1);
出:=FILTER(EE,10);
DRAWICON(出,0,1);
低位金叉:= CROSS(中DIFF,中DEA) AND 中DIFF<(-0.1);
DRAWTEXT(低位金叉,0.21,' 低位金叉'),COLORWHITE;
A:=CROSS(中DIFF,中DEA);
两次金叉:=CROSS(中DIFF,中DEA)AND COUNT(A,20)=2 AND MACD>REF(MACD,1);
DRAWTEXT(两次金叉,中DIFF,'20日内2次金叉'),COLORYELLOW;
JCCOUNT:=COUNT(CROSS(中DIFF,中DEA),BARSLAST(中DEA>=0));
低位二次金叉:=CROSS(中DIFF,中DEA) AND 中DEA<0 AND COUNT(JCCOUNT=2,21)=1;
DRAWTEXT(低位二次金叉,0.25,'低位二次金叉'),COLORYELLOW;
OBV:=中DIFF;
P:=5;
A1:=REF(OBV,P)=HHV(OBV,2*P+1);
B1:=FILTER(A1,P);
C1:=BACKSET(B1,P+1);
D11:=FILTER(C1,P);{高点}
A2:=REF(OBV,P)=LLV(OBV,2*P+1);
B2:=FILTER(A2,P);
C2:=BACKSET(B2,P+1);
D22:=FILTER(C2,P);{低点}
R11:=BACKSET(ISLASTBAR,BARSLAST(D11)+1);
S11:=R11>REF(R11,1);
DRAWLINE(D11,OBV,S11,OBV,1),COLORBLUE;
T11:=BACKSET(ISLASTBAR,BARSLAST(D22)+1);
U11:=T11>REF(T11,1);
DRAWLINE(D22,OBV,U11,OBV,1),COLOR00FF00;
DRAWICON(D11,OBV,14);
DRAWICON(D22,OBV,13);
主升 : 中DIFF>0 AND 中DIFF>中DEA,COLOR0000FF,POINTDOT,NODRAW;
STICKLINE(主升,中DIFF,中DEA,0.5,0),COLOR0000FF;
VAR2:=REF(LOW,1);
VAR3:=SMA(ABS(LOW-VAR2),3,1)/SMA(MAX(LOW-VAR2,0),3,1)*100;
VAR4:=EMA(IF(CLOSE*1.3,VAR3*10,VAR3/10),3);
VAR5:=LLV(LOW,13);
VAR6:=HHV(VAR4,13);
VAR7:=IF(MA(CLOSE,34),1,0);
VAR8:=EMA(IF(LOW<=VAR5,(VAR4+VAR6*2)/2,0),3)/618*VAR7;
VAR9:=IF(VAR8>100,100,VAR8);
VAR10:=IF(VAR9>-120,VAR9,0);
VAR11:=VAR10<REF(VAR10,1);
DRAWTEXT(VAR11 AND REF(NOT(VAR11),1),-0.5,'★'),COLORBLUE;
通达信中短MACD金叉与死叉指标公式