以下是通达信一根线搞定DMI指标公式源码
通达信一根线搞定DMI指标公式源码:
N:=21;M:=6;M1:=20;
TR1:=Ema(MAX(MAX(HIGH-LOW,Abs(HIGH-REF(CLOSE,1))),ABS(REF(CLOSE,1)-LOW)),N);
HD:=HIGH-REF(HIGH,1);
LD:=REF(LOW,1)-LOW;
DMP:=EMA(IF(HD 0ANDHD LD,HD,0),N);
DMM:=EMA(IF(LD 0ANDLD HD,LD,0),N);
pdi:=DMP*100/TR1;
mdi:=DMM*100/TR1;
ADX:EMA((PDI-MDI)/(MDI+PDI)*100,M)*2;
ADXR:EMA(ADX,M);
ADMA:EMA(ADX,M1);
OMD:(ADX-2*ADMA+ADXR)/2,COLORstICK;
DRAWBAND(ADX,RGB(155,50,50),ADXR,RGB(0,100,50));
STICKLINE(OMD REF(OMD,1)ANDOMD 0,0,OMD,1,0),COLORRED;
STICKLINE(OMD REF(OMD,1)ANDOMD 0,0,OMD,1,0),COLORGREEN;
STICKLINE(OMD REF(OMD,1),0,OMD,1,0),COLORCBCBC0;
STICKLINE(OMD =0OROMD =0,0,0,50,1),COLORWHITE;
ADX1:ADX,COLORRED;
ADXR1:ADXR,COLORGREEN;
ADMA1:ADMA;
强:IF(ADX1 =ADXR1,ADX1,DRAWNULL),COLORRED,LINETHICK3;
买入:IF(OMD 0ANDOMD-REF(OMD,1) 0,30,0);
{OMD;}
110;
0;
DRAWICON(crOSS(ADX,ADXR),ADX+5,1);
MTR:=EXPMEMA(MAX(MAX(HIGH-LOW,Abs(HIGH-REF(CLOSE,1))),ABS(REF(CLOSE,1)-LOW)),14);
HD:=HIGH-REF(HIGH,1);
LD:=REF(LOW,1)-LOW;
DMP:=EXPMEMA(IF(HD 0 HD LD,HD,0),14);
DMM:=EXPMEMA(IF(LD 0 LD HD,LD,0),14);
pdi:=DMP*100/MTR;
mdi:=DMM*100/MTR;
DM:=PDI-MDI,NODRAW;
TRR1:=EMA(MAX(MAX(H-L,ABS(H-REF(C,1))),ABS(REF(C,1)-L)),14);
DMP1:=EMA(IF(HD 0 HD LD,HD,0),14);
DMM1:=EMA(IF(LD 0 LD HD,LD,0),14);
ADX0:=EMA((DMP1-DMM1)/(DMP1+DMM1)*100,6);
ADXR0:=EMA(ADX0,6);
PDI1:=DMP1/TRR1*100;
MDI1:=DMM1/TRR1*100;
DM1:=PDI1-MDI1;
AAJ:=(3*ADX0-2*ADXR0);
MAAD:=(ADX0-ADXR0),NODRAW;
ADXR:EXPMEMA(ADX,6),POINTDOT,LINETHICK7,COLORGREEN;
IF(DM 0,ADXR,DRAWNULL),POINTDOT,LINETHICK7,COLORRED;
助涨:DRAWICON(DM 0ANDADX ADXRANDADX 20,ADXR,15);
助跌:DRAWICON(DM 0ANDADX ADXRANDADX 20,ADXR,12);
DRAWICON(crOSS(ADXR0,ADX0)ANDADXR0 60,ADXR*1.2,8);
DRAWICON(CROSS(ADXR0,ADX0)ANDADXR0 60,ADXR*1.4,2);
20,COLORYELLOW,DOTLINE;
60,COLORGREEN,DOTLINE;
N:=14;M:=6;ADXP:=1;
TR:=SMA(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(LOW-REF(CLOSE,1))),N,1);
HD:=HIGH-REF(HIGH,1);
LD:=REF(LOW,1)-LOW;
DMP:=SMA(IF(HD 0ANDHD LD,HD,0),N,1);
DMM:=SMA(IF(LD 0ANDLD HD,LD,0),N,1);
PDI:DMP*200/TR,COLORRED;
MDI:DMM*200/TR,COLORBLUE;
ADX:SMA(ABS(MDI-PDI)/(MDI+PDI)*200,M,1),COLORYELLOW;
ADXR:(ADX+REF(ADX,M))/2,COLORMAGENTA,LINETHICK2;
IF(ADX ADXR,ADXR,0),COLOR00FF00,LINETHICK2;
IF(PDI REF(PDI,1),PDI,0),COLORBLUE,LINETHICK1;
IF(MDI REF(MDI,1),MDI,0),COLORRED,LINETHICK1;
STICKLINE(ADX =REF(ADXR,1),ADX,ADXR,1,0),COLOR00FF00;
STICKLINE(ADX REF(ADXR,1),ADX,ADXR,1,0),COLORMAGENTA;
STICKLINE(REF(PDI,1) PDI,PDI,REF(PDI,1),1,0),COLORRED;
STICKLINE(REF(PDI,1) PDI,PDI,REF(PDI,1),1,0),COLORBLUE;
STICKLINE(REF(MDI,1) MDI,MDI,REF(MDI,1),1,0),COLORRED;
STICKLINE(REF(MDI,1) MDI,MDI,REF(MDI,1),1,0),COLORBLUE;
{传统MDI加进四条线}
CD0:16,POINTDOT;
CD1:30,POINTDOT;
TD0:60,POINTDOT;
TD1:80,POINTDOT;
DRAWTEXT(CROSS(PDI,CD0),CD0,'●金'),COLORMAGENTA;
DRAWTEXT(CROSS(TD0,PDI),PDI,'●死'),COLORBLUE;
DRAWTEXT(CROSS(ADX,CD0),CD0,'●金'),COLORMAGENTA;
DRAWTEXT(CROSS(TD0,ADX),ADX,'●死'),COLORBLUE;
DRAWTEXT(CROSS(PDI,MDI),MDI,'★金'),COLORYELLOW;
DRAWTEXT(CROSS(MDI,PDI),PDI,'★死'),COLORGREEN;
DRAWTEXT(CROSS(ADX,ADXR),ADXR,'★金'),COLOR000999;
DRAWTEXT(CROSS(ADXR,ADX),ADX,'★死'),COLORCYAN;
通达信一根线搞定DMI指标公式截图