WebCab Technical Analysis
(J2EE Edition)

com.webcab.ejb.finance.trading.indicators
Interface DirectionalMovementIndicator

All Superinterfaces:
EJBObject, Remote

public interface DirectionalMovementIndicator
extends EJBObject

Within this class we implement the Directional Movement Indicator (MDI) and Average Directional Indicator (ADX) which was first developed by Wellas Wilder in order to classify price moves and trends. The ideas where first made public within Wilder's first book "New Concepts in Technical Trading Systems" (Dec 1978).

These ideas where originally developed into a trading system and can still be used as such. Today these methods are most commonly used to evaluate the strength of a price move or trend. Care should be taken with the direct application of this approach since it was first developed and applied to markets with exhibited lower volatility than todays markets.

The central idea of this approach is to compare the range of price of two subsequent days and from this information infer the overall direction of the market. In order to ensure the stability of the indicators a moving average is often used in conjunction with the basic indicators. For further details please see the PDF documentation.


Method Summary
 double averageDailyTrueRange(double[] trueRange)
          We evaluate the x-day Average Daily True Range (ADTR) of an asset over a period.
 int classifyMovements(double todaysHigh, double todaysLow, double yesterdaysHigh, double yesterdaysLow)
          The Directional Movement Indicator (DMI) approach required the previous days price action to be compared to todays price actions.
 double directionalMotion(double plusDirectionalMovement, double minusDirectionalMovement)
          This indicator the directional indicator forms the main part of the Directional Movement System developed by Wellas Wilder.
 double directionalMotion(double todaysHigh, double todaysLow, double yesterdaysHigh, double yesterdaysLow, double yesterdaysClose)
          Evaluates the directional movement indicator (DMI).
 double minusDirectionalMovement(double trueRange, double minusDirectionalMovement)
          Minus Directional Movement Indicator (DMI)
 double minusDirectionalMovement(double todaysHigh, double todaysLow, double yesterdaysHigh, double yesterdaysLow)
          The Minus Directional Movement (MDM) is evaluated
 double minusDirectionalMovement(double todaysHigh, double todaysLow, double yesterdaysHigh, double yesterdaysLow, double yesterdaysClose)
          Minus Directional Movement Indicator (DMI) is evaluated form the source data
 double plusDirectionalMovement(double trueRange, double positiveDirectionalMovement)
          Plus Directional Movement Indicator (DMI) of todays price action.
 double plusDirectionalMovement(double todaysHigh, double todaysLow, double yesterdaysHigh, double yesterdaysLow, double yesterdaysClose)
          Plus Directional Movement Indicator (DMI) of an asset.
 double positiveDirectionalMovement(double todaysHigh, double todaysLow, double yesterdaysHigh, double yesterdaysLow)
          The Positive Directional Movement (PDM) is evaluated
 double trueRange(double todaysHigh, double todaysLow, double yesterdaysClose)
          True Range (TR) of a traded asset today.
 double wilderAverageDirectionalMotion(double todaysHigh, double todaysLow, double yesterdaysHigh, double yesterdaysLow, double yesterdaysClose, double nDaysHigh, double nDaysLow, double yesterdaysNDaysHigh, double yesterdaysNDaysLow, double yesterdaysNDaysClose)
          Evaluates the Average Directional Movement Index Rating (ADXR), which is a component of the Directional Movement System developed by Welles Wilder.
 
Methods inherited from interface javax.ejb.EJBObject
getEJBHome, getHandle, getPrimaryKey, isIdentical, remove
 

Method Detail

classifyMovements

public int classifyMovements(double todaysHigh,
                             double todaysLow,
                             double yesterdaysHigh,
                             double yesterdaysLow)
                      throws RemoteException
The Directional Movement Indicator (DMI) approach required the previous days price action to be compared to todays price actions. In particular, we compare the range of the todays price with yesterdays range of prices and classify the price dynamics according to the following categories: where:

This method we return a different integer depending on the classification of past two days price action. This integers are defined as:

Remarks:

Parameters:
todaysHigh - the highest traded value which the asset under consideration takes during todays market action
todaysLow - the lowest traded value which the asset under consideration takes during todays market action
yesterdaysHigh - the highest traded value which the asset under consideration takes during yesterdays market action
yesterdaysLow - the lowest traded value which the asset under consideration takes during yesterdays market action
Throws:
IllegalArgumentException - thrown if any of the parameters todaysHigh, todaysLow, yesterdaysHigh or yesterdaysLow is a strictly negative number.
RemoteException

positiveDirectionalMovement

public double positiveDirectionalMovement(double todaysHigh,
                                          double todaysLow,
                                          double yesterdaysHigh,
                                          double yesterdaysLow)
                                   throws RemoteException
The Positive Directional Movement (PDM) is evaluated

Parameters:
todaysHigh - the highest traded value which the asset under consideration takes during todays market action
todaysLow - the lowest traded value which the asset under consideration takes during todays market action
yesterdaysHigh - the highest traded value which the asset under consideration takes during yesterdays market action
yesterdaysLow - the lowest traded value which the asset under consideration takes during yesterdays market action
Throws:
IllegalArgumentException - thrown if any of the parameters todaysHigh, todaysLow, yesterdaysHigh or yesterdaysLow is a strictly negative number.
RemoteException

minusDirectionalMovement

public double minusDirectionalMovement(double todaysHigh,
                                       double todaysLow,
                                       double yesterdaysHigh,
                                       double yesterdaysLow)
                                throws RemoteException
The Minus Directional Movement (MDM) is evaluated

Parameters:
todaysHigh - the highest traded value which the asset under consideration takes during todays market action
todaysLow - the lowest traded value which the asset under consideration takes during todays market action
yesterdaysHigh - the highest traded value which the asset under consideration takes during yesterdays market action
yesterdaysLow - the lowest traded value which the asset under consideration takes during yesterdays market action
Throws:
IllegalArgumentException - thrown if any of the parameters todaysHigh, todaysLow, yesterdaysHigh or yesterdaysLow is a strictly negative number.
RemoteException

trueRange

public double trueRange(double todaysHigh,
                        double todaysLow,
                        double yesterdaysClose)
                 throws RemoteException
True Range (TR) of a traded asset today. Also, described as the True Range (TR) of the current bar.

Parameters:
todaysHigh - the highest traded value of the asset today
todaysLow - the lowest traded value of the asset today
yesterdaysClose - the close price of the asset the preceding day
Throws:
IllegalArgumentException - thrown if any of the parameters todaysHigh, todaysLow or yesterdaysClose is a strictly negative number.
RemoteException
See Also:
averageDailyTrueRange

averageDailyTrueRange

public double averageDailyTrueRange(double[] trueRange)
                             throws RemoteException
We evaluate the x-day Average Daily True Range (ADTR) of an asset over a period. This measure is often used as a measure of volatility. The ADTR is the simple moving average of daily true values.

Parameters:
trueRange - an array of (positive) doubles of length x, where the first element is the true range on the last trading session, the second value of the true range range on the previous trading session and so on.
Throws:
IllegalArgumentException - thrown if any element of the array is strictly negative. The elements of the trueRange array cannot be strictly negative since they represent the (positive) true range's (TRs) of an asset over a period.
RemoteException
See Also:
trueRange

plusDirectionalMovement

public double plusDirectionalMovement(double trueRange,
                                      double positiveDirectionalMovement)
                               throws RemoteException
Plus Directional Movement Indicator (DMI) of todays price action.

Parameters:
trueRange - the true range of the Current Bar (i.e. todays)
positiveDirectionalMovement - the positive directional movement of the asset of the past day
RemoteException
See Also:
trueRange, positiveDirectionalMovement

minusDirectionalMovement

public double minusDirectionalMovement(double trueRange,
                                       double minusDirectionalMovement)
                                throws RemoteException
Minus Directional Movement Indicator (DMI)

Parameters:
trueRange - the true range of the Current Bar (i.e. todays)
minusDirectionalMovement - the minus directional movement of the asset of the past day
Throws:
IllegalArgumentException - thrown if the trueRange is not positive.
RemoteException
See Also:
trueRange, minusDirectionalMovement

plusDirectionalMovement

public double plusDirectionalMovement(double todaysHigh,
                                      double todaysLow,
                                      double yesterdaysHigh,
                                      double yesterdaysLow,
                                      double yesterdaysClose)
                               throws RemoteException
Plus Directional Movement Indicator (DMI) of an asset.

Parameters:
todaysHigh - the highest traded value which the asset under consideration takes during todays market action
todaysLow - the lowest traded value which the asset under consideration takes during todays market action
yesterdaysHigh - the highest traded value which the asset under consideration takes during yesterdays market action
yesterdaysLow - the lowest traded value which the asset under consideration takes during yesterdays market action
yesterdaysClose - the close price of the asset the preceding day
Throws:
IllegalArgumentException - thrown if any of the parameters todaysHigh, todaysLow, yesterdaysHigh, yesterdaysLow or yesterdaysClose is not a positive number.
RemoteException

minusDirectionalMovement

public double minusDirectionalMovement(double todaysHigh,
                                       double todaysLow,
                                       double yesterdaysHigh,
                                       double yesterdaysLow,
                                       double yesterdaysClose)
                                throws RemoteException
Minus Directional Movement Indicator (DMI) is evaluated form the source data

Parameters:
todaysHigh - the highest traded value which the asset under consideration takes during todays market action
todaysLow - the lowest traded value which the asset under consideration takes during todays market action
yesterdaysHigh - the highest traded value which the asset under consideration takes during yesterdays market action
yesterdaysLow - the lowest traded value which the asset under consideration takes during yesterdays market action
yesterdaysClose - the close price of the asset the preceding day
Throws:
IllegalArgumentException - thrown if any of the parameters todaysHigh, todaysLow, yesterdaysHigh, yesterdaysLow or yesterdaysClose is not a positive number.
RemoteException

directionalMotion

public double directionalMotion(double todaysHigh,
                                double todaysLow,
                                double yesterdaysHigh,
                                double yesterdaysLow,
                                double yesterdaysClose)
                         throws RemoteException
Evaluates the directional movement indicator (DMI). When a trend is moving with strength, the directional indicator (ADX) will measure the strength of the trend by measuring the spread between the Plus directional Indicator (PDI) and Minus Directional Indicator (MDI).

The Directional Movement Indicator (DMI) can be summarized by the following formula:

((PDM - MDM)/(PDP + MDM)) * 100,

where,

Interpretation
The Directional movement indicator has a range of [0,100], where to higher the value returned the stronger the trend is said to be. If a trend is reliable then the directional lines (PDM and MDM) will diverge and the indicator will increase. If on the other hand a trend starts to fail and price whip-saws (for example with price is within a trading range) the difference between the direction lines will decrease and the overall index will decrease.

Parameters:
todaysHigh - the highest traded value which the asset under consideration takes during todays market action
todaysLow - the lowest traded value which the asset under consideration takes during todays market action
yesterdaysHigh - the highest traded value which the asset under consideration takes during yesterdays market action
yesterdaysLow - the lowest traded value which the asset under consideration takes during yesterdays market action
yesterdaysClose - the closing price of the asset the preceding day
Throws:
IllegalArgumentException - thrown if any of the parameters todaysHigh, todaysLow, yesterdaysHigh, yesterdaysLow or yesterdaysClose is not a positive number.
RemoteException
See Also:
plusDirectionalMovement, minusDirectionalMovement

directionalMotion

public double directionalMotion(double plusDirectionalMovement,
                                double minusDirectionalMovement)
                         throws RemoteException
This indicator the directional indicator forms the main part of the Directional Movement System developed by Wellas Wilder. This indicator is generally evaluated using 14 periods and is used with the plusDirectionalMovement and minusDirectionalMovement indicators.

The directional movement indicator can be summarized by the following formula:

((up - down)/(up+down)) * 100,

where,

Interpretation
The directional indicator has a range of [0,100], where to higher the value returned the stronger the trend is said to be. If a trend is reliable then the smoothed directional lines (PDM and MDM) will diverge and the indicator will increase. If on the other hand a trend starts to fail and price whip-saws (for example with price is within a trading range) the difference between the smoothed direction lines will decrease and the overall index will decrease.

Parameters:
plusDirectionalMovement - the value of the Plus Directional Movement indicator
RemoteException
See Also:
plusDirectionalMovement, minusDirectionalMovement

wilderAverageDirectionalMotion

public double wilderAverageDirectionalMotion(double todaysHigh,
                                             double todaysLow,
                                             double yesterdaysHigh,
                                             double yesterdaysLow,
                                             double yesterdaysClose,
                                             double nDaysHigh,
                                             double nDaysLow,
                                             double yesterdaysNDaysHigh,
                                             double yesterdaysNDaysLow,
                                             double yesterdaysNDaysClose)
                                      throws RemoteException
Evaluates the Average Directional Movement Index Rating (ADXR), which is a component of the Directional Movement System developed by Welles Wilder. The ADXR should be considered as a special type of moving average (WilderMA) or or equivalently as a filter which can be applied to the Directional Indicator.

Originally Welles Wilder used the ADXR indicator to determine whether a trend was sufficiently strong enough in order to apply a trend following system. The rule was to only apply a trend following system when the ADXR was between 20 and 25. The ADMR can also be used within a system which uses the Directional Movement Indicator (for example Welles, Directional Movement System) which will result in trading signals being more infrequently generated.

This indicator is given by the following formula:

ADXR = (directionalMotion(today) + directionalMotion(n-days ago))/2

where directionalMotion(today) in the value of the Directional Motion Index (above) today and directionalMotion(n-days ago) is the Directional Motion Index of the asset under consideration n-days ago.

Parameters:
todaysHigh - the highest traded value which the asset under consideration takes during todays market action
todaysLow - the lowest traded value which the asset under consideration takes during todays market action
yesterdaysHigh - the highest traded value which the asset under consideration takes during yesterdays market action
yesterdaysLow - the lowest traded value which the asset under consideration takes during yesterdays market action
yesterdaysClose - the closing price of the asset the preceding day
nDaysHigh - the highest traded value which the asset under consideration takes during the trading period n-days previously
nDaysLow - the lowest traded value which the asset under consideration takes during the trading period n-days previously
yesterdaysNDaysHigh - the highest traded value which the asset under consideration takes during the trading period (n+1)-days previously
yesterdaysNDaysLow - the lowest traded value which the asset under consideration takes during the trading period (n+1)-days previously
yesterdaysNDaysClose - the closing price of the asset on the trading period (n+1) days ago
Throws:
IllegalArgumentException - thrown if any of the methods double parameters is not a positive number.
RemoteException

WebCab Technical Analysis
(J2EE Edition)