X_1:=SMA(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(LOW-REF(CLOSE,1))),7,1);
X_2:=HIGH-REF(HIGH,1);
X_3:=REF(LOW,1)-LOW;
X_4:=SMA(IF(X_2 0 AND X_2 X_3,X_2,0),7,1);
X_5:=SMA(IF(X_3 0 AND X_3 X_2,X_3,0),7,1);
PDI:X_4*100/X_1;
MDI:X_5*100/X_1;
ADX:SMA(ABS(MDI-PDI)/(MDI+PDI)*100,7,1);
ADXR:(ADX+REF(ADX,7))/2;