通达信DMI,MACD.RSI背离指标公式
2020/10/27 18:44:07
N:=14;
MM:=6;
RSV:=(CLOSE-LLV(LOW,10))/(HHV(HIGH,10)-LLV(LOW,10))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
J:=3*K-2*D;
DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA), COLORSTICK;
LC:=REF(CLOSE,1);
RSI1:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100;
RSI2:=SMA(MAX(CLOSE-LC,0),12,1)/SMA(ABS(CLOSE-LC),12,1)*100;
RSI3:=SMA(MAX(CLOSE-LC,0),24,1)/SMA(ABS(CLOSE-LC),24,1)*100;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(CLOSE,A1+1)>CLOSE AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);
MACD底背离:FILTER(B1>0,5);
STICKLINE(FILTER(B1>0,5),0,10,1,0),COLOR00FF00;
DRAWTEXT(FILTER(B1>0,5),10,'MACD底背'),COLOR00FF00;
A3:=BARSLAST(REF(CROSS(RSI1,RSI2),1));
B3:=REF(CLOSE,A3+1)>CLOSE AND REF(RSI1,A3+1)<RSI1 AND CROSS(RSI1,RSI2);
RSI底背离:FILTER(B3>0,5),LINETHICK0;
STICKLINE(FILTER(B3>0,5),0,30,1,0),COLORFFFF00;
DRAWTEXT(FILTER(B3>0,5),30,'RSI底背'),COLORFFFF00;
C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));
D1:=REF(CLOSE,C1+1)<CLOSE AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF);
MACD顶背离:FILTER(D1>0,5),LINETHICK0;
STICKLINE(FILTER(D1>0,5),100,80,1,0),COLOR0066FF;
DRAWTEXT(FILTER(D1>0,5),80,'MACD顶背'),COLOR0066FF;
C3:=BARSLAST(REF(CROSS(RSI2,RSI1),1));
D3:=REF(CLOSE,C3+1)<CLOSE AND REF(RSI1,C3+1)>RSI1 AND CROSS(RSI2,RSI1);
RSI顶背离:FILTER(D3>0,5),LINETHICK0;
STICKLINE(FILTER(D3>0,5),100,80,1,0),COLOR15F70A;
DRAWTEXT(FILTER(D3>0,5),80,'RSI顶背'),COLOR15F70A;
{以上不动}
TR1:=EMA(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(REF(CLOSE,1)-LOW)),21);
HD :=HIGH-REF(HIGH,1);
LD :=REF(LOW,1)-LOW;
DMP:=EMA(IF(HD>0 AND HD>LD,HD,0),21);
DMM:=EMA(IF(LD>0 AND LD>HD,LD,0),21);
PDI:= DMP*100/TR1;
MDI:= DMM*100/TR1;
ADX: EMA((PDI-MDI)/(MDI+PDI)*100,6)*2;
ADXR:EMA(ADX,6);
ADMA:=EMA(ADX,20);
OMD:(ADX-2*ADMA+ADXR)/2, COLORSTICK;
DRAWBAND(ADX,RGB(155,50,50),ADXR,RGB(0,100,50));
STICKLINE(OMD>REF(OMD,1) AND OMD>0,0,OMD,1,0),COLORRED;
STICKLINE(OMD>REF(OMD,1) AND OMD<0,0,OMD,1,0),COLORGREEN;
STICKLINE(OMD<REF(OMD,1),0,OMD,1,0),COLORCBCBC0;
STICKLINE(OMD>=0 OR OMD<=0,0,0,50,1),COLORWHITE;
ADX1:ADX,COLORRED;
ADXR1:ADXR,COLORYELLOW;
{DMI顶底背离}
DM1:=BARSLAST(REF(CROSS(ADX1,ADXR1),1));
DM2:=REF(CLOSE,DM1+1)>CLOSE AND REF(ADX1,DM1+1)<ADX1 AND CROSS(ADX1,ADXR1);
DMI底背离:FILTER(DM2>0,5),LINETHICK0;
DRAWTEXT(FILTER(DM2>0,5),ADX1,'DMI底背'),COLORFFFF00;
DM3:=BARSLAST(REF(CROSS(ADXR1,ADX1),1));
DM4:=REF(CLOSE,DM3+1)<CLOSE AND REF(ADX1,DM3+1)>ADX1 AND CROSS(ADXR1,ADX1);
DMI顶背离:FILTER(DM4>0,5),LINETHICK0;
DRAWTEXT(FILTER(DM4>0,5),ADX1,'DMI顶背'),COLORGREEN;
投股票 网 www .tou18.cn
股市公式下载推荐