Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Riccardo Ronco
BAPV rronco@bloomberg.net riccardo@rronco.freeserve.co.uk
Directional Movement
Directional movement is the most fascinating concept I have studied. Defining it is a little like chasing the end of a rainbow you can see it, you know its there, but the closer you get to it the more elusive it becomes. I have probably spent more time studying directional movement than any other concept. Certainly one of the most satisfying achievements was the day I was actually able to reduce this concept to an absolute mathematical equation WELLES WILDER
DMI formulas
This is reprinted in part from Volume 11, Issue 4,of the STOCKS & COMMODITIES article, "The ADX" by Thom Hartle. Figure 1 shows the five ADX cases that have to be resolved. In example A, the second day's trading range is higher than the first day's trading range, indicating positive directional movement. In example B, the second day's trading range is below the first day's trading range, an indication of negative directional movement. Example C is more complicated because the second day's range is both lower and higher than the first day's range. Directional movement is only considered to be up, down or not present. Therefore, the larger part of the day's range extending beyond the previous day's range is used to identify directional movement. In example C, the largest part of the second day is higher; consequently, the directional movement is positive. In example D, the largest part of the second day's range is lower so that the directional movement is negative. In example E, the second day's range is within the first day's range so the directional movement is zero. In the Excel 4.0 spreadsheet (Figure 2), the first calculation for ADX is the true range value (TR). This is performed in column E. The formula for cell E3 is: =MAX(B3-C3,ABS(B3-D2),ABS(C3-D2)) Next, column F determines the positive directional movement or returns zero if there is no positive directional movement. The formula for cell F3 is: =IF(B3-B2>C2-C3,MAX(B3-B2,0),0) Column G calculates the negative directional movement or returns zero if there is no negative directional movement. The formula for cell G3 is: =IF(C2-C3>B3-B2,MAX(C2-C3,0),0) The daily calculations are volatile and so the data needs to be smoothed. First, sum the last 14 periods for TR, +DM and - DM. The formula for summing the TR is in cell H16: =SUM(E3:E16) ADX spreadsheet. Here is the output for the S&P 500 from January 1 to February 11, 1992. The formula for summing the +DM is in cell I16: =SUM(F3:F16) The formula for summing the -DM is in cell J16: =SUM(G3:G16) The smoothing formula for the TR14 column begins at cell H17: =TRUNC((H16-(H16/14)+E17),3) The smoothing formula subtracts 1/14th of yesterday's TR14 from yesterday's TR14 and then adds today's TR value. The truncating function is used to calculate the indicator as close as possible to the developer of the ADX's original form of calculation (which was done by hand). The smoothing formula for the +DM14 column begins at cell I17: =TRUNC((I16-(I16/14)+F17),3) The smoothing formula subtracts 1/14th of yesterday's +DM14 from yesterday's +DM14 and then adds today's +DM value. The smoothing formula for the -DM14 column begins at cell J17: =TRUNC((J16(J16/14)+G17),3) The smoothing formula subtracts 1/14th of yesterday's -DM14 value from yesterday's -DM14 and then adds today's -DM value. Now we have a 14-day smoothed sum of TR, +DM and -DM. The next step is to calculate the ratios of +DM and -DM to TR. The ratios are called the +directional indicator (+DI) and directional indicator (-DI). The formula for the +DI column begins at cell K16: =INT(100*(I16/H16)) The formula for the +DI column begins at cell L16: =INT(100*(J16/H16)) The integer function (INT) is used because the original developer dropped the values after the decimal in the original work on the ADX indicator. The next step is to calculate the absolute value of the difference between the +DI and the -DI. This is done in column M and the formula for cell M16:=ABS(K16-L16) The next column calculates the sum of the +DI and -DI. The formula for cell N16: =K16+L16 The next step is to calculate the DX, which is the ratio of the absolute value of the difference between the +DI and the -DI divided by the sum of the +DI and the -DI. This is done in column O. The formula for cell O16: =INT(100*(M16/N16)) The final step is smoothing the DX to arrive at the value of the ADX. First, average the last 14 days of DX values. The formula for cell P28: =AVERAGE(O15:O28) The smoothing process uses yesterday's ADX value multiplied by 13, and then add today's DX value. Finally, divide this sum by 14. The formula for cell P29: =INT(((P28*13)+O29)/14) Additional reading Wilder, J. Welles [1978]. New Concepts in Technical Trading Systems, Trend Research.
1.
Same problem that a simple / exponential moving average with the same DMI length can have, that is: it does not work in a choppy market because of many false signals.
2.
DMI crossover indicates the trend direction in the same way the direction of the moving average or the crossover of the close with its moving average does, so it looks like that there is no particular advantage in using DMI versus a moving average.
3.
Common risk in over optimization when developing trading systems using DMI to fit a given time series.
A) It is actually possible to find interesting bottom / top patterns to trade or to insert in our existing trading systems (plenty of space to improve this pattern). B) There are 3 parameters (DM indicator length, threshold level, number of days to exit) so, again, the risk in over fitting is still here C) Testing stocks using daily bars we find that: - DM indicator interesting length is between 3 6 days (short term trading only then); - The threshold level is between 5 and 10 (really oversold / overbought conditions); - Ideal profitable holding period goes from 5 to 10 days; - ~ 55% profitable; - Profit factor (gross profit / gross losses) between 1.15 1.35; - Ratio average win / average loss ~ 1.00 (ideal for short term only).
{Show Me Study: DMI Exhaustion Test adapted for STA Meeting 15th November 2000 Coded by Riccardo Ronco 1995 2000 riccardo@rronco.freeserve.co.uk} Input: Length(5),Level(5); IF DMIPlus(Length) <= Level Then Begin Plot1(Low - 5 points,"DMI Ex Low"); IF CheckAlert Then Alert = TRUE; End; IF DMIMinus(Length) <= Level Then Begin Plot2(High + 5 points,"DMI Ex High"); IF CheckAlert Then Alert = TRUE; End;
a) b) c) d) e) f) g)
It is always in the market (Stop and Reverse); For a LONG position (BUY Setup) the DM+ is above its moving average AND the DM- is below its moving average; For a SHORT position (SELL Setup) the DM+ is below its moving average AND the DM- is above its moving average; BUY on breakout of the High of the day we have a BUY setup; SELL on breakout of the Low of the day we have a SELL setup; A condition to exit the position when congestion is detected can be added to reduce the time spent in the market; Testing results are consistent and stable trough a wide range of parameters.
{System: DMI Evolution Trading System Stop and Reverse, Trend Following, No commissions, no slippage, no reinvestment Setup: DMI direction confirmed by BOTH exp moving averages Entry: Breakout next bar (High for LONG, Low for SHORT) adapted for STA Meeting 15th November 2000 Coded by Riccardo Ronco 1995 2000 riccardo@rronco.freeserve.co.uk} Input: Length(14),Ema(3); IF (DMIPlus(Length) > Xaverage(DMIPlus(Length),Ema)) and (DMIMinus(Length) < Xaverage(DMIMinus(Length),Ema)) Then Buy High + 1 point Stop; IF (DMIPlus(Length) < Xaverage(DMIPlus(Length),Ema)) and (DMIMinus(Length) > Xaverage(DMIMinus(Length),Ema)) Then Sell Low - 1 point Stop;
The Structure
DMI PEAK structure (Strength = 1)
DM+
Long Entry on b/o Highest High last 2 bars
Peak
Trough
{Function: DMIPeaks Long Exit A Strenght 1 DMI+ trough is defined by one preceding and one following bars with HIGHER DMI+ values. When this condition is found we save the LOWEST LOW of the last two bars since this value is a support level adapted for STA Meeting 15th November 2000 Coded by Riccardo Ronco riccardo@rronco.freeserve.co.uk} Input: Len(Numeric); Value1 = DMIPlus(Len); DMIPLX = IFF( value1 > value1[1] and value1[1] < value1[2], Lowest(Low, 2), DMIPLX[1]);
{Function: DMIPeaks Short Entry A Strenght 1 DMI- peak is defined by one preceding and one following bars with LOWER DMIvalues. When this condition is found we save the LOWEST LOW of the last two bars since this value is a bearish breakout level adapted for STA Meeting 15th November 2000 Coded by Riccardo Ronco riccardo@rronco.freeserve.co.uk} Input: Len(Numeric); Value1 = DMIMinus(Len); DMIPSE = IFF( value1 <= value1[1] and value1[1] > value1[2], Lowest(Low, 2), DMIPSE[1]);
{Function: DMIPeaks Short Exit A Strenght 1 DMI- trough is defined by one preceding and one following bars with HIGHER DMI- values. When this condition is found we save the HIGHEST HIGH of the last two bars since this value is a resistance level adapted for STA Meeting 15th November 2000 Coded by Riccardo Ronco riccardo@rronco.freeserve.co.uk} Input: Len(Numeric); Value1 = DMIMinus(Len); DMIPSX = IFF( value1 > value1[1] and value1[1] < value1[2], Highest(High, 2), DMIPSX[1]);
{System: DMI Peaks adapted for STA Meeting 15th November 2000 Coded by Riccardo Ronco riccardo@rronco.freeserve.co.uk} Inputs: Length(9); Vars: mp(0); mp = marketposition; Buy DMIPLE(Length) + 1 point stop; Sell DMIPSE(Length) - 1 point stop; if mp > 0 then Exitlong DMIPLX(Length) - 1 point stop; if mp < 0 then Exitshort DMIPSX(Length) + 1 point stop;
{Indicator: DMI Peaks adapted for STA Meeting 15th November 2000 Coded by Riccardo Ronco riccardo@rronco.freeserve.co.uk} Input: Length(9); Plot1(DMIPLE(Length),"DMIPLE"); Plot2(DMIPLX(Length),"DMIPLX"); Plot3(DMIPSE(Length),"DMIPSE"); Plot4(DMIPSX(Length),"DMIPSX"); IF CheckAlert Then Begin IF Plot1 Crosses Above Plot2 or or Plot1 Crosses Above Plot3 or or Plot1 Crosses Above Plot4 or or Plot2 Crosses Above Plot3 or or Plot2 Crosses Above Plot4 or or Plot3 Crosses Above Plot4 or Then Alert = TRUE; End;
References
1. 2. 3. 4. 5. 6. 7. 8.
Wilder, J.Welles [1978]. New Concepts In Technical Trading Systems, Trend Research. Hochheimer Vaughn [1982]. Computerized Trading Techniques, Merrill Lynch Comm. Lukac, Brorsen, Irwin [1985]. A Comparison of 12 Trading Systems, Traders Press. LeBeau Lucas [1992]. Computer Analysis Of The Futures Market, Business One Irwin. Blau, William [1995]. Momentum, Direction And Divergence, John Wiley & Sons. Chande, Tushar S. [1997]. Beyond Technical Analysis, John Wiley & Sons. Kaufman, Perry J. [1998]. Trading Systems And Methods (3rd ed.), John Wiley & Sons. Evens, Stuart [1999]. Stocks & Commodities Feb 199 p. 66.