# calculate Directional Movement Index (DMI)

Version 1.0.0.0 (2.58 KB) by
% CALCDMI - calculate Directional Movement Index (DMI) for a given stock using high, low, close
Updated 5 Nov 2012

- this function was first written in 2006
- after several request I am finally sending it to file exchange at 2012
- please re-check function validation as it was along time ago and

CALCDMI - calculate Directional Movement Index (DMI) for a given
stock using high, low, close

[ ADX, ADXR, PDI, MDI] = calcDMI( high, low, close, M, N),
INPUT:
high - data vector of high prices
low - data vector of low prices
close - data vector of close prices
M - days to avreage, optional
N- days to sum +DI and -DI, optional

OUTPUT:
PDI - +DM, plus Directional Indicator
MDI - -DM, minus Directional Indicator

EXAMPLES:
% read JNJ stock from yahoo URL

% reshape response
s=reshape(s,[],length(s)/7)';
disp(s);

high = str2double(s(2:end,3));
low = str2double(s(2:end,4));
close = str2double(s(2:end,5));

% call function

Directional movement is a system for providing trading signals to be used for price breaks from a trading range.
The system involves 5 indicators which are the Directional Movement Index (DX), the plus Directional Indicator (+DI),
the minus Directional Indicator (-DI), the average Directional Movement (ADX) and the Directional movement rating (ADXR).
The system was developed J. Welles Wilder and is explained thoroughly in his book, New Concepts in Technical Trading Systems .
The basic Directional Movement Trading system involves plotting the 14day +DI and the 14 day -DI on top of each other.
When the +DI rises above the -DI, it is a bullish signal.
A bearish signal occurs when the +DI falls below the -DI.
To avoid whipsaws, Wilder identifies a trigger point to be the extreme price on the day the lines cross.
If you have received a buy signal, you would wait for the security to rise above the extreme price (the high price on the day the lines crossed).
If you are waiting for a sell signal the extreme point is then defined as the low price on the day's the line cross.

\$License: BSD (use/copy/change/redistribute on own risk, mention the
author) \$
History:
001: Natanel Eizenberg: 14-May-2006 21:52, First version.
002: Natanel Eizenberg: 04-Nov-2012 21:52, Edit for file exchange.

### Cite As

natanel (2024). calculate Directional Movement Index (DMI) (https://www.mathworks.com/matlabcentral/fileexchange/38905-calculate-directional-movement-index-dmi), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2006b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Transaction Cost Analysis in Help Center and MATLAB Answers