通达信真正的MACD背离指标公式

通达信扬帆起航主图指标公式

通达信真正的MACD背离指标公式:

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

DEA:EMA(DIF,9);

macd:(DIF-DEA)*2,COLORstICK;

{底部信号}

BB值:=EMA(100*(C-LLV(LOW,34))/(HHV(H,34)-LLV(LOW,34)),3);

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

DRAWTEXT(crOSS(BB值,9),0, '‘底部'),COLORYELLOW;

DRAWICON(CROSS(BB值,9),0,41);

STICKLINE(CROSS(BB值,9),AAA,0,2,0),COLORYELLOW;

{DRAWICON(REF(DIF,1)>REF(DIF,2) AND DIF<REF(DIF,1) AND DIF>0 AND DIF>DEA,DIF*1.1,2),COLORGREEN;

DRAWICON(CROSS(DEA,DIF) AND DIF>0,DIF,37),COLORGREEN;

DRAWICON(REF(DIF,1)<REF(DIF,2) AND DIF>REF(DIF,1) AND DIF<0 AND DIF<DEA,DIF*1.1,1),COLORRED;

DRAWICON(CROSS(DIF,DEA) AND DIF<0,DIF,36),COLORRED;}

X_2:=BArslAST(REF(MacD,1)<0 AND MACD>0);

X_3:=LLVBARS(MACD,X_2+20);

X_4:=IF(X_3>X_2,REF(MACD,X_3),0);

X_5:=MACD<0 AND MACD>X_4 AND LOW=LLV(LOW,X_2+20) AND X_4<0;

X_6:=REF(X_5,1)=1 AND MACD>REF(MACD,1) AND REF(DIF,X_3)<0 AND MACD<0;

低背:DRAWLINE(X_4=X_3,MACD,X_6,MACD,0),COLORRED,LINETHICK2;

DRAWICON(X_6,MACD*1.2,26);

X_7:=HHVBARS(MACD,X_2+20);

X_8:=IF(X_7>X_2,REF(MACD,X_7),0);

X_9:=MACD>0 AND MACD<X_8 AND HIGH=HHV(HIGH,X_2+20) AND X_8>0;

X_10:=REF(X_9,1)=1 AND MACD>REF(MACD,1) AND REF(DIF,X_7)>0;

顶背:DRAWLINE(X_8=X_7,MACD,X_10,MACD,0),COLORGREEN,LINETHICK2;

DRAWICON(X_10,MACD*1.2,15);

X_11:=CLOSE/MA(CLOSE,40)*100<78;

X_12:=CLOSE/MA(CLOSE,60)*100<74;

X_13:=HIGH>LOW*1.051;

X_14:=X_13 AND COUNT(X_13,5)>1;

X_15:=IF(X_14 AND (X_11 OR X_12),2,0);

X_16:=CLOSE/REF(CLOSE,25)<=1.1;

X_17:=SMA(MAX(CLOSE-REF(CLOSE,2),0),7,1)/SMA(Abs(CLOSE-REF(CLOSE,2)),7,1)*100<15;

X_18:=(CLOSE-LLV(LOW,8))/(HHV(HIGH,8)-LLV(LOW,8))*100;

X_19:=SMA(X_18,2,1);

X_20:=SMA(X_19,2,1);

X_21:=IF(X_19>REF(X_19,1) AND REF(X_19,1)<REF(X_19,2) AND X_19<23,1.5,0);

抄底:X_16 AND X_15 AND X_17 AND X_21 ,COLORWHITE;

{X_22:=100-100*(HHV(HIGH,5*8)-CLOSE)/(HHV(HIGH,5*8)-LLV(LOW,5*8));

X_23:=MA(CLOSE,5);

X_24:=IF(CLOSE>SAR(10,2,20),1,0);

X_25:=IF(CLOSE<SAR(10,2,20),(-1),0);

X_26:=ATAN((X_23/REF(X_23,1)-1)*100)*180/3.1416;

X_27:=IF(X_26>30,1,0);

X_28:=IF(X_26<(-30),(-1),0);

X_29:=X_24+X_27+X_25+X_28;}

{线变色}

{IF(X_29<(-1) OR X_22<25.01,DIF,DRAWNULL),COLORGREEN,LINETHICK1;

IF(X_22>74.989998 OR X_29>0,DIF,DRAWNULL),COLORRED,LINETHICK1;}

VA1:=HHVBARS(MACD,BARSLAST(MACD<0)+1);

VA2:=CROSS(BACKSET(CROSS(0,MACD) OR (ISLASTBAR AND MACD>0),REF(VA1,1)+2),0.5);

前高:DRAWLINE(VA2,MACD,REF(VA2,1),REF(MACD,1),1),COLORYELLOW,POINTDOT ;

VA3:=LLVBARS(MACD,BARSLAST(MACD>0)+1);

VA4:=CROSS(BACKSET(CROSS(MACD,0) OR (ISLASTBAR AND MACD<0),REF(VA3,1)+2),0.5);

前低:DRAWLINE(VA4,MACD,REF(VA4,1),REF(MACD,1),1),COLORYELLOW,POINTDOT ;

启动点:=MACD<0 AND MACD>REF(MACD ,1) AND REF(MACD ,1)<REF(MACD ,2)AND REF(MACD ,2)<REF(MACD ,3)AND REF(MACD ,3)<REF(MACD ,4);

STICKLINE(启动点,0.2,MACD,0.3,0),COLORYELLOW COLORYELLOW;

{STICKLINE(MACD>REF(MACD,1) AND MACD>0,0,MACD,1.8,0),COLOR000055;

STICKLINE(MACD>REF(MACD,1) AND MACD>0,0,MACD,1.1,0),COLOR000099;

STICKLINE(MACD>REF(MACD,1) AND MACD>0,0,MACD,0.6,0),COLOR0000BB;}

启动点A:0,COLORYELLOW;

{DRAWICON(启动点,2,11);}

{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;

A:=CROSS(DIF,DEA) AND CROSS(K,D) AND CROSS(J,D);

DRAWICON(A,DEA*1.2,25);

DRAWTEXT(A,DEA*1.2, ' 金叉共振'),COLORYELLOW;

0,COLORGRAY,DOTLINE;

{rsi买入}

wrSI:=SMA(MAX(CLOSE-REF(CLOSE,1),0),6,1)/SMA(ABS(CLOSE-REF(CLOSE,1)),6,1)*100;

相对强弱RSI买入:=CROSS(WRSI,20),STICK,LINETHICK2,COLORYELLOW;

{RSI买入:STICKLINE(CROSS(WRSI,20),0,70,0,0),LINETHICK2,COLORYELLOW;}

STICKLINE(相对强弱RSI买入,0-0.1,MACD-0.1,0.3,0),COLORRED;

DRAWTEXT(相对强弱RSI买入,MACD-0.1, '‘入'),COLORYELLOW;

{背离}

A3:=BARSLAST(REF(CROSS("RSI.RSI1","RSI.RSI2"),1));

B3:=REF(C,A3+1)>C AND REF("RSI.RSI1",A3+1)<"RSI.RSI1" AND CROSS("RSI.RSI1","RSI.RSI2");

DRAWTEXT(B3>0,-0.3,'RSI底离'),COLORCYAN;{RSI底背离};

C3:=BARSLAST(REF(CROSS("RSI.RSI2","RSI.RSI1"),1));

D3:=REF(C,C3+1)<C AND REF("RSI.RSI1",C3+1)>"RSI.RSI1" AND CROSS("RSI.RSI2","RSI.RSI1");

DRAWTEXT(D3>0,0.5,'RSI顶离'),COLORGREEN;{RSI顶背离};

通达信MFI优化及选股指标公式