When Welles Wilder created his ADX indicator (and the Directional Movement idea) he was doing all the math by hand. You can still see the worksheets he used in his book. His way to make the Average of some numbers was just to take yesterday’s value, divide it by the period, multiply this number times period minus 1 and add today’s value divided the period. Over time this became the Wilder’s average. Since he used normally a 14-period average he was making only 4 operations instead of 15 …. and that was a lot of time saved!!
Needless to say that his average was not the most precise (I could write a lot more on averages) but it was the quickest to calculate and good enough to make his indicators to work fine.
Today with the help of computers we can get much more. I wrote the directional movement code with the possibility to change the type of moving average used. I personally use a weighted moving average and the performance of Wilder’s indicator is, in my opinion and experience, much better.
Blue skies!!
//period=14
//mm=2
//computation of Directional Movement indicators
up=high-high[1]
dw=low[1]-low
if up>dw and up>=0 then
plusdm=up
else
plusdm=0
endif
if dw>up and dw>=0 then
mindm=dw
else
mindm=0
endif
//computation of TR
mioTR=max(abs(high-close),max(abs(low-close),range))
mioATR=average[period,MM](mioTR)
//computation of DI
dip=100*average[period,MM](plusdm)/mioATR
dim=100*average[period,MM](mindm)/mioATR
mioDI=dip-dim
//computation of ADX e ADXR
mioADX=100*average[period,MM](abs(dip-dim)/(dip+dim))
mioADXR=(mioADX+mioADX[14])/2
//return of data
return dip coloured (0,205,0) as "DI+", dim coloured (205,0,0) as"DI-", miodi style (histogram) as "DI",mioadx as "ADX", mioadxr coloured (204,0,204) as "ADXR",0