calculate Directional Movement Index (DMI)

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

View License

- 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:
ADX - Directional Movement Index
ADXR - Directional movement rating
PDI - +DM, plus Directional Indicator
MDI - -DM, minus Directional Indicator

EXAMPLES:
% read JNJ stock from yahoo URL
url2Read ='http://ichart.finance.yahoo.com/table.csv?s=JNJ&a=0&b=12&c=2010&d=9&e=23&f=2012&g=d&ignore=.csv';
s=urlread( url2Read);

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

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

% call function
[ ADX, ADXR, PDI, MDI] = calcDMI( high, low, close);

information from http://www.trade10.com/Directional_Movement.html
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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0