n:=14;m:=6;
TR := SUM(MAX(MAX(HIGH-LOW,Abs(HIGH-REF(CLOSE,1))),ABS(LOW-REF(CLOSE,1))),N);
HD := HIGH-REF(HIGH,1);
LD := REF(LOW,1)-LOW;
DMP:= SUM(IF(HD>0 AND HD>LD,HD,0),N);
DMM:= SUM(IF(LD>0 AND LD>HD,LD,0),N);
pdi: DMP*100/TR;
mdi: DMM*100/TR;
ADX: MA(ABS(MDI-PDI)/(MDI+PDI)*100,M),LINETHICK4,COLORff0000;
PARTLINE(adx,(adx>=REF(adx,1) and pdi>mdi),RGB(255,0,0)),LINETHICK4;
{- }
ADXR:(ADX+REF(ADX,M))/2,COLOR888888;
PARTLINE(adxr,(adxr>=REF(adxr,1) and pdi>mdi),RGB(255,0,255)),LINETHICK2;
FILLRGN(pdi,mdi,pdi>mdi,RGB(150,0,150),pdi