The Directional Movement Index is an indicator created by J. Welles Wilder, Jr. It is used to help identify in which direction a financial instrument is moving on a scale from zero to one hundred. The calculation is performed as follows:
For each bar, first find the directional movement (DM) value and find out whether the directional movement is positive, negative, or zero. This is calculated as follows:
If the current bar is an inside bar (the current bar’s high is less than the previous bar’s high and the current bar’s low is greater than the previous bar’s close) or an equal bar (the current bar’s high is equal to the previous bar’s high and the current bar’s low is equal to the previous bar’s low), the DM is zero.
If the directional movement is not zero, directional movement is calculated by seeing if the current bar has moved further up or down compared with the previous bar. This is done by comparing the following two values:
If current bar’s high is greater than the previous bar’s high, Value 1 equals the current bar’s high minus, the previous bar’s high; otherwise Value 1 equals zero.
If current bar’s low is less than the previous bar’s low, Value 2 equals the current bar’s low minus, the previous bar’s low; otherwise Value 2 equals zero.
If Value 1 is greater than Value 2, Value 1 is the directional movement value and the directional movement is positive.
If Value 2 is greater than Value 1, Value 2 is the directional movement value and the directional movement is negative.
If Value 1 is equal to Value 2, the directional movement value is zero.
After finding the directional movement, you need to calculate the directional indicator (DI),
For each bar, first find the true range:
The true range will be the largest of these three values:
The absolute value of the bar’s high - the bar’s low
The absolute value of the previous bar’s close - the bar’s high
The absolute value of the previous bar’s close - the bar’s low
Divide the directional movement by the true range and multiply by 100 to get the directional indicator. This represents the percent of the true range that is up or down for the bar.
You now decide over what time period you want to calculate directional movement. Let’s assume you want a 14 day period (the indicator’s default). For each of the first 14 bars, add up all of the true ranges (We’ll call this the 14 bar true range). Then add up all of the positive directional movements and divide this number by the totaled true ranges. (We’ll call this the 14 bar Plus DM.) Also add up all of the negative directional movements and divide this number by the totaled true ranges. (We’ll call this the 14 bar Minus DM.)
Now for each new bar, we calculate the 14 bar Plus and Minus DM and true range as follows:
The current bar’s 14 bar Plus DM = the previous bar’s 14 bar Plus DM - (the previous bar’s 14 bar Plus DM / 14) + the current bar’s Plus DM.
The current bar’s 14 bar Minus DM = the previous bar’s 14 bar Minus DM - (the previous bar’s 14 bar Minus DM / 14) + the current bar’s Minus DM.
The current bar’s 14 bar true range = the previous bar’s 14 bar true range - (the previous bar’s 14 bar true range / 14) + the current bar’s true range.
This allows for a smoothing effect on the DM’s. Note that either the current bar’s Plus or Minus DM will be zero, so nothing will be added.
Now we calculate the directional movement index (DX).
If the current bar’s 14 bar Plus DM is greater than the current bar’s 14 bar Minus DM, the calculation is:
DX = (the current bar’s 14 bar Plus DM - the current bar’s 14 bar Minus DM) / (the current bar’s 14 bar Plus DI + the current bar’s 14 bar Minus DI) * 100
otherwise the calculation is:
DX = (the current bar’s 14 bar Minus DM - the current bar’s 14 bar Plus DM) / (the current bar’s 14 bar Plus DI + the current bar’s 14 bar Minus DI) * 100
After you’ve calculated 14 DXs, the average directional movement index (ADX) is obtained by adding the DXs and dividing by 14. You then calculate the next ADXs by multiplying the previous bar’s ADX by 13, adding today’s DX value, and then dividing by 14.
The average directional movement index rating (ADXR) is obtained by adding the current bar’s ADX value with the ADX value of 14 bars ago and dividing by 2.
Reference: Wilder, J. Welles, Jr. New Concepts in Technical Trading Systems. Winston-Salem, NC: Hunter Publishing Company., 1978.