Sharing investing and trading ideas. Helping traders get started.
Advertisement

Tuesday, June 30, 2009

Directional Movement Index

Directional Movement Index DMX
Comes with formula, calculation steps and VBA code

Introduction
The directional movement index, DMX is derived from the positive and negative directional movement indicators, +DMI and -DMI. It is calculated as follows.

DMX = Absolute of [+DMI - (-DMI)] / [+DMI + (-DMI)]

The +DMI is the Welles Wilder's moving average of +DM over n days divided by the average true range for n days. -DMI is calculated in the same way. +DM refers to positive directional movement. Intuitively, it can be thought of as the change in the day's high. On the other hand, -DM or negative directional movement refers to the change in the day's low.

The directional movement index or DMX normalizes the absolute difference in DMI against the sum of +DMI and -DMI. It shows the strength in the current trend net of both upwards and downwards movement. If + DMI is similar in value to the -DMI, the value of DX will be small reflecting a weak trend. However, DX strictly tells nothing about the direction, only the strength of the trend because it is always an absolute value.

VBA Code
Method A uses functions, while Method B uses sub procedures to calculate DMI. Method B is faster and more flexible.

Method A
To calculate +/-DMX, you need the following custom functions from the respective pages

DM function from directional movement
TR function from average true range

Calculate the following.
  1. +DM and -DM, "=DM([current high], [current low], [previous high], [previous low])". Select the cell and the neigbouring cell right next to it, press F2 and Crtl+Shift+Enter. DM is an array function, returning both +DM and -DM
  2. WWMA for +/- DM by entering in another cell "=WWMA([previous WWMA],[current +/-DM],[n])".
  3. True range, "=TR([high],[low],[previous close])"
  4. Average true range, "=WWMA([previous WWMA],[current TR],[n])"
  5. +/-DMI=output from step 2 /output from step 4
  6. DMX, "=DMX([+DMI],[-DMI])
'Paste this code into your ThisWorkBook code window in VBA. Right Click This WorkBook in Project Explorer and click View Code.
Private Sub Workbook_Open()
AddUDF
End Sub

'The rest belong to any module
Sub AddUDF()
'Tells Excel to includes these in list of functions, add descriptions to them and create a new category called Technical Indicators.
Application.MacroOptions macro:="DMX", _
Description:="Returns Directional Movement Index" & Chr(10) & Chr(10) & _
"Select positive and negative directional movement indicators", _
Category:="Technical Indicators"
End Sub

Public Function DMX(PosDMI, NegDMI)
DMX = Abs(PosDMI - NegDMI) / (PosDMI + NegDMI)
End Function

Method B
Method B offers the benefit of not having to the intermediate outputs, such as DMI yourself. It does everything for you. To run Method B, you have to copy the Runthis sub of Method B from the page on Accumulation/Distribution line. You will run the DMX_1 sub from the Runthis sub.

You will also need the DMI_1, DM_1, WWMA_1, ATR_1 subs of Method B from the directional movement indicator, directional movement, Welles Wilder's moving average and the average true range pages respectively.

'Copy the following line into the Runthis sub
'Just before the line End Sub
'Disable all other macros that Runthis will call e.g. CLV, ADL, by
'marking them out as comments with single quotes
DMX_1 high, low, close1, output, n

'Insert this as a new sub
Sub DMX_1(high As Range, low As Range, close1 As Range, output As Range, n As Long)
DMI_1 high, low, close1, output, n
output(0, 9).Value = "DMX"
PosDMI = output(3, 7).Address(False, False)
NegDMI = output(3, 8).Address(False, False)
output(3, 9).Value = "=abs(" & PosDMI & "-" & NegDMI & ")/(" & PosDMI & "+" & NegDMI & ")"
output(3, 9).Copy output.Offset(0, 8)
Range(output(1, 9), output(2, 9)).Clear
End Sub

Other References

http://fxtrade.oanda.com/learn/graphs/indicators/adx.shtml


Like what you have just read? Digg it or Tip'd it.
The objective of Finance4Traders is to help traders get started by bringing them unbiased research and ideas. Since late 2005, I have been developing trading strategies on a personal basis. Not all of these models are suitable for me, but other investors or traders might find them useful. After all, people have different investment/trading goals and habits. Thus, Finance4Traders becomes a convenient platform to disseminate my work...(Read more about Finance4Traders)

0 comments:

Post a Comment