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

Monday, June 29, 2009

Average Directional Index

Average Directional Index ADX
Comes with formula, calculation steps and VBA code

Introduction
The average directional index, ADX is a relatively complex indicator involving a total of five other technical studies. They are Welles Wilder's moving average, average true range, directional movement, directional movement indicator and directional movement index. The ADX is a measure of trend strength, but not a measure of direction. You might want to visit the pages above before reading further.

The calculation of the ADX invovles four major steps.
  1. Calculate the directional movement of each period based on the period high and low.
  2. Smooth the directional movement using the Welles Wilder's moving average and divide the result by the average true range for the last n days to obtain the directional movement indicator.
  3. Compute the directional movement index from the directional movement indicator to determine the strength of prevailing trend.
  4. Smooth the directional movement index using the Welles Wilder's moving average to obtain the average directional index.
Thus, the ADX is a smoothed view of trend strength. The ADX does not measure market direction because the directional movement index is always a positive value. Its formula is as follows:

ADX=WWMA of DMX over k periods

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 average directional index, ADX, you need the following custom functions from the respective pages

DM function from directional movement
TR function from average true range
DMX function from directional movement index

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])
  7. ADX, "=WWMA([previous ADX], [current DMX], [n])"
As can be seen, the calculation of the ADX is actually a WWMA function of DMX. I try to avoid writing custom functions that only run another custom function because it is repetitive. The function of ADX if I were to write one, will look like this

Public Function ADX(ADXPrevious, DMX, n)
ADX=WWMA(ADXPrevious,DMX,n)
End Function

Sub AddUDF()
Application.MacroOptions macro:="ADX", _
Description:="Returns Average Directional Movement Index" & Chr(10) & Chr(10) & _
"Select previous period's ADX, current DMX and n", _
Category:="Technical Indicators"
End Sub

The ADX function above merely passes the same inputs to the WWMA function.

Method B
Method B is much more convenient because it calculates the intermediate outputs 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 ADX_1 sub from the Runthis sub.

You will need the DM_1, WWMA_1, ATR_1, DMI_1, DMX_1 subs of Method B from the directional movement, Welles Wilder's moving average, the average true range, directional movement indicator, directional movement index 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
ADX_1 high, low, close1, output, n

'Insert this as a new sub
Sub ADX_1(high As Range, low As Range, close1 As Range, output As Range, n As Long)
DMX_1 high, low, close1, output, n
WWMA_1 output.Offset(0, 8), output.Offset(0, 9), n
output(0, 10).Value = "ADX"
output(2, 10).Copy output(4, 10)
Range(output(2, 10), output(3, 10)).Clear
End Sub

ADX_1 only has seven lines because much of the work is done by the DMX_1 and WWMA_1 subs.

The ADX is used in the calculation of the average directional movement rating ADR.

Other References





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)

3 comments:

ADmin said...

It should not happen extremely regularly that you are asked to compose a paper on a subject you know nothing in regards to this site.

Arsalan Yousuf said...

What a nice short methods and to the point blog post - perfectly demonstrating the effectiveness of your points! coursework writing

Essay writing services said...

A very nice piece of art shown by the writer as this article..You just have nailed it..Essay writing services

Post a Comment