WebCab Technical Analysis
v1.1
(J2SE Edition)

webcab.lib.finance.trading.indicators
Class AccumulateDistribute

java.lang.Object
  |
  +--webcab.lib.finance.trading.indicators.AccumulateDistribute
All Implemented Interfaces:
Serializable

public class AccumulateDistribute
extends Object
implements Serializable

Provides indicators which measure to what degree an asset is being accumulated (brought) or distributed (sold) by the market as a whole.

One Period and Multi Period Versions

For many of the indicators we provide essentially two versions of the same method. The first version evaluates the indicator over the entire period given and the second version evaluates the indicator over all the sub-periods of a given length. Moreover, the version which evaluates over all sub-periods of a given length will return the results as an array where the 1st term of the array will be the value associated with the most recent sub-period, and the previous element corresponding to the previous sub-period and so on.

The naming of these two versions will follow the convention that if the indicator which evaluates over the entire period and returns a single element is named ABCIndicator, then the corresponding indicator over all sub-periods (of a given length) which returns an array will be denoted by ABCIndicatorOverPeriod.

For example, if our source data has N elements then the two versions of a given indicator, where the number of periods used within the sub-periods is n would correspond to:

  1. ABCIndicator - Evaluation of the indicator over the whole period of length N.
  2. ABCIndicatorOverPeriod - Will return an array where the first term is the value of the indicator ABCIndicator on the most recent n periods, and the next term is the value of the indicator ABCIndicator on the previous n+1 periods minus the most recent period and so on. That is, for each iterative evaluation 'the window of evaluation' is shifted one place back.

See Also:
Serialized Form

Constructor Summary
AccumulateDistribute()
          Creates a new instance.
 
Method Summary
 double[] accumulateDistributionOverPeriod(double[] high, double[] low, double[] volume, int lengthOfPeriod)
          Evaluates the accumulation/distribution indicator for each of the (sub)collection of periods of a given length.
 double accumulationDistribution(double high, double low, double volume)
          The accumulation/distribution indicator illustrates the degree to which an asset is being accumulated or reduced by the market on a given period.
 double accumulationDistributionPeriod(double[] highs, double[] lows, double[] volume)
          Evaluates the accumulation/distribution indicator over a number of periods.
 double chaikinMoneyFlow(double[] high, double[] low, double[] closing, double[] volume)
          Chaikin Money Flow (CMF) is a volume weighted average of Accumulation/Distribution over a specified period, which is usually taken to be 21 days.
 double[] chaikinMoneyFlowOverPeriod(double[] high, double[] low, double[] close, double[] volume, int lengthOfPeriod)
          Iteratively evaluates the Chaikin Money Flow (CMF) indicator over all (sub)collections of periods of a given length for all periods for which data is provided.
 double chaikinOscillator(double[] high, double[] low, double[] volume, double smoothingFactor)
          Implements the Chaikin Oscillator (also known as the Chaikin A/D Oscillator) and evaluates this indicator for the latest period.
 double[] chaikinOscillatorOverPeriod(double[] high, double[] low, double[] volume, double smoothingFactor)
          Implements the Chaikin Oscillator (also known as the Chaikin A/D Oscillator) and evaluates this indicator for the latest and all previous periods for which there exists sufficient data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccumulateDistribute

public AccumulateDistribute()
Creates a new instance.

Method Detail

accumulationDistribution

public double accumulationDistribution(double high,
                                       double low,
                                       double volume)
The accumulation/distribution indicator illustrates the degree to which an asset is being accumulated or reduced by the market on a given period. The indicator uses the closing price's proximity to the high or low to determine if accumulation or reduction is taking place in the market. The proximity measure is also multiplied by the volume in order to give more weight to moves with correspondingly higher volume.

Application

A divergence between the price action and this indicator can signal that a trend is nearing completion, a trends continuation and imminent break-outs from trading ranges. The actual value of this indicator is of no significance, what is significant is its change in value relative to the previous periods which can warn of a possible break-out during a trading range (falling/rising indicator), the continuation of a trend (higher highs in uptrend, or lower lows in downtrend) or a change/completion of a trend (divergence between the price action and the direction of the indicator).

Parameters:
high - the intra-period high for the given period under consideration
low - the intra-period low for the given period under consideration
volume - the days volume for the given period under consideration
Returns:
A double equal to the value of the accumulation/distribution indicator for a single period for this asset considered.
Throws:
IllegalArgumentException - thrown if any of the parameters are strictly negative numbers.
See Also:
accumulationDistributionPeriod - a slight variation which measures the Accumulation/Distribution over a period.

accumulationDistributionPeriod

public double accumulationDistributionPeriod(double[] highs,
                                             double[] lows,
                                             double[] volume)
Evaluates the accumulation/distribution indicator over a number of periods. The accumulation/distribution indicator illustrates the degree to which an asset is being accumulated or distributed by the market over these periods. The indicator uses the closing price's proximity to the high or low over the period to determine if accumulation or reduction is taking place in the market. The proximity measure is also multiplied by the volume over the period in order to give more weight to moves with correspondingly higher volume.

Remark: This indicator is a slight generalization of the accumulationDistribution(double, double, double) indicator. Here the indicator may be evaluated with respect to a period of a days rather than with respect to a one day period.

Interpretation

A divergence between the price action and this indicator can signal that a trend is nearing completion, a trends continuation and break-outs from trading ranges. The actual value of this indicator is of no significance, what is significant is its change in value relative to the previous periods which can warn of a possible break-out during a trading range (falling/rising indicator), the continuation of a trend (higher highs in uptrend, or lower lows in downtrend) or a change/completion of a trend (divergence between the price action and the direction of the indicator).

Parameters:
highs - an array where the first term is the intraday high over the most recent period, the second term is the high over the previous period and so on.
lows - an array where the first term is the intraday low over the most recent periods, the second term is the high over the previous period and so on.
volume - an array where the first terms is the trading volume of the asset considered over the most recent periods, the second term is the volume over the previous period and on so.
Returns:
A double which is the value of the accumulation/distribution indicator evaluated over a period. That is, the amount of accumulation or distribution which takes place for the asset considered over the period considered.
Throws:
IllegalArgumentException - throw when the three arrays highs, lows, volume do not have the same length, or when any element of these three arrays is a strictly negative number.
See Also:
accumulationDistribution

accumulateDistributionOverPeriod

public double[] accumulateDistributionOverPeriod(double[] high,
                                                 double[] low,
                                                 double[] volume,
                                                 int lengthOfPeriod)
Evaluates the accumulation/distribution indicator for each of the (sub)collection of periods of a given length. The accumulation/distribution indicator illustrates the degree to which an asset is being accumulated or distributed by the market over each of these collection of periods. The indicator uses the closing price's proximity to the high or low over the period to determine if accumulation or reduction is taking place in the market. The proximity measure is also multiplied by the volume over the period in order to give more weight to moves with correspondingly higher volume.

Interpretation

A divergence between the price action and this indicator can signal that a trend is nearing completion, a trends continuation and break-outs from trading ranges. The actual value of this indicator is of no significance, what is significant is its change in value relative to the previous periods which can warn of a possible break-out during a trading range (falling/rising indicator), the continuation of a trend (higher highs in uptrend, or lower lows in downtrend) or a change/completion of a trend (divergence between the price action and the direction of the indicator).

Example

Say for example we know that:

  1. Highs = {3, 4, 3, 4, 5}, i.e. 3 is the high from the latest period.
  2. Lows = {2, 1, 2, 1, 3}, i.e. 2 is the low from the latest period.
  3. Volume = {300, 290, 295, 285, 290}, i.e. 300 is the volume in the latest period.

Now if the lengthOfPeriod considered is 4, then this method will return an array of length two where the first term is the accumulation\distribution indicator (evaluated using accumulationDistribution) when:

  1. Highs = {3, 4, 3, 4}, i.e. above Highs with the last element removed.
  2. Lows = {2, 1, 2, 1}, i.e. above Highs with the last element removed.
  3. Volume = {300, 290, 295, 285} i.e. above Highs with last element removed.
and the second term is the accumulation/distribution indicator when:
  1. Highs = {4, 3, 4, 5}, i.e. the window moves one position back.
  2. Lows = {1, 2, 1, 3}, i.e. the window moves one position back.
  3. Volume = {290, 295, 285, 290}, i.e. the window moves one position back.

Parameters:
high - an array where the first term is the intraday high over the most recent period, the second term is the high over the previous period and so on.
low - an array where the first term is the intraday low over the most recent periods, the second term is the high over the previous period and so on.
volume - an array where the first terms is the trading volume of the asset considered over the most recent periods, the second term is the volume over the previous period and on so.
lengthOfPeriod - an integer which represents the number of periods within each of the (sub)collection of periods over which the indicator is evaluated.
Returns:
Array with the k-th term corresponds to the accumulation/distribution indicator over the k-th previous period.
Throws:
IllegalArgumentException - throw when the three arrays highs, lows, volume do not have the same length, or when any element of these three arrays is a strictly negative number.
See Also:
accumulationDistribution - measure the accumulate/distribution on an asset over a single trading period.

chaikinOscillator

public double chaikinOscillator(double[] high,
                                double[] low,
                                double[] volume,
                                double smoothingFactor)
Implements the Chaikin Oscillator (also known as the Chaikin A/D Oscillator) and evaluates this indicator for the latest period. The Chaiken Oscillator presents the information contained within the A/D indicator in the convenient form of an oscillator. That is, the Chaikin Oscillator is simply the Moving Average Convergence Divergence indicator (MACD) applied to the Accumulation/Distribution Line.

Interpretation

A sell signal is when price action develops a higher high into overbought zones and the Chaikin Oscillator diverges with a lower high and begins to fall. Conversely, a buy signal is generated when price action develops a lower low into oversold zones and the oscillator diverges with a higher low and begins to rise. The Chaikin Oscillator can also be used to time entry to existing trends by either buying the dip (when the oscillator turns down) or selling the rally (when the oscillator turns up).

Evaluation

The Chaiken Oscillator is given by:

Chaiken Oscillator = EMA3(Accumulate/Distribution) - EMA10(Accumulate/Distribution),

where EMA3 and EMA10 is the exponential moving average over 3 and 10 days respectively; and Accumulate/Distribution is the corresponding indicator over those 3 or 10 days respectively.

Parameters:
high - an array of 10 elements where the first term is the high in the last trading period, the second term is the high in the trading period before that, and so on
low - an array of 10 elements where the first term is the low in the last trading period, the second term is the low in the trading period before that, and so on
volume - an array of 10 elements where the first term is the volume in the last trading period, the second term is the volume in the trading period before that, and so on
smoothingFactor - the number between 0 and 1. The lower the number the more sensitive the moving average is.
Returns:
The value of the Chaikin Oscillator for the most recent period.
Throws:
IllegalArgumentException - thrown when the three arrays high, low, volume do not have the same length and when the smoothing factor does not lie within the closed interval [0,1].
See Also:
chaikinOscillatorOverPeriod - a slight generalization of this indicator, here the indicator may be evaluated with respect to a period of a days. This method implements the Chaikin Oscillator over a period (also known as the Chaikin A/D Oscillator).

chaikinOscillatorOverPeriod

public double[] chaikinOscillatorOverPeriod(double[] high,
                                            double[] low,
                                            double[] volume,
                                            double smoothingFactor)
Implements the Chaikin Oscillator (also known as the Chaikin A/D Oscillator) and evaluates this indicator for the latest and all previous periods for which there exists sufficient data. The Chaiken Oscillator presents the information contained within the A/D indicator in the convenient form of an oscillator. That is, the Chaikin Oscillator is simply the Moving Average Convergence Divergence indicator (MACD) applied to the Accumulation/Distribution Line.

Interpretation

A sell signal is when price action develops a higher high into overbought zones and the Chaikin Oscillator diverges with a lower high and begins to fall. Conversely, a buy signal is generated when price action develops a lower low into oversold zones and the oscillator diverges with a higher low and begins to rise. The Chaikin Oscillator can also be used to time entry to existing trends by either buying the dip (when the oscillator turns down) or selling the rally (when the oscillator turns up).

Evaluation

The Chaiken Oscillator for a given period is given by:

Chaiken Oscillator = EMA3(Accumulate/Distribution) - EMA10(Accumulate/Distribution),

where EMA3 and EMA10 is the exponential moving average over 3 and 10 days respectively; and Accumulate/Distribution is the corresponding indicator over those 3 or 10 days respectively.

Illustration

If we are provided within the high, low and volume over the last 15 periods, then we will be able to evaluate the Chaikin Oscillator on the previous 5 trading days. Since the evaluation of the oscillator on a given period requires knowledge of the 10 previous periods data.

Parameters:
high - an array of at least 10 elements where the first term is the high in the last trading period, the second term is the high in the trading period before that, and so on
low - an array of at least 10 elements where the first term is the low in the last trading period, the second term is the low in the trading period before that, and so on
volume - an array of at least 10 elements where the first term is the volume in the last trading period, the second term is the volume in the trading period before that, and so on
smoothingFactor - the number between 0 and 1. The lower the number the more sensitive the indicator is.
Returns:
An array where the first term is the value of the oscillator using the last 10 days data, the previous term is the value of the oscillator on the previous period and so on.
Throws:
IllegalArgumentException - thrown when the three arrays high, low, volume do not have the same length and when the smoothing factor does not lie within the closed interval [0,1].
See Also:
chaikinOscillator

chaikinMoneyFlow

public double chaikinMoneyFlow(double[] high,
                               double[] low,
                               double[] closing,
                               double[] volume)
Chaikin Money Flow (CMF) is a volume weighted average of Accumulation/Distribution over a specified period, which is usually taken to be 21 days. The CMF offers a volume weighted indicator on the following two principles:

Interpretation

A sell signal is generated in positive over brought territory when higher highs diverge into a lower high and the indicator continues to decrease. Conversely, a buy signal in generated in negative oversold territory when lower lows diverge into a high low and the indicator continues to increase.

The CMF indicator can be used as a confirmation signal after a breakout of a trading range. When a market breaks higher then the breakout is confirmed if the CMF moves into positive territory and continues to get stronger. Conversely, if the market down after a trading range then the breakout if confirmed if the CMF move into negative territory and continues to weaken.

Evaluation

The CMF indicator is evaluated for the following steps:

Parameters:
high - an array where the first term in the high in the latest trading period and the second term is the high in the previous trading periods and so on... Until the last term which is the highest market price during the first period which is used in the evaluation of the CMF indicator
low - an array where the first term in the low in the latest trading period and the second term is the low in the previous trading periods and so on... Until the last term which is the lowest market price during the first period which is used in the evaluation of the CMF indicator.
closing - an array where the first term is the closing price in the latest trading period and the second term is the closing price in the previous trading periods and so on... Until the last term which is the closing price during the first period which is used in the evaluation of the CMF indicator
volume - an array where the first term in the volume in the securities latest trading period and the second term is the securities volume in the previous trading periods and so on... Until the last term which is the securities volume during the first period which is used in the evaluation of the CMF indicator
Returns:
Double value equal to the Chaikin Money Flow (CMF) for the latest trading period.
Throws:
IllegalArgumentException - thrown if the arrays high, low, close, volume do not have the same length or if any element of these arrays is a strictly negative number.
See Also:
chaikinMoneyFlowOverPeriod - a slight generalization of this indicator, in that here we iteratively evaluate the Chaikin Money Flow (CMF) indicator over periods.

chaikinMoneyFlowOverPeriod

public double[] chaikinMoneyFlowOverPeriod(double[] high,
                                           double[] low,
                                           double[] close,
                                           double[] volume,
                                           int lengthOfPeriod)
Iteratively evaluates the Chaikin Money Flow (CMF) indicator over all (sub)collections of periods of a given length for all periods for which data is provided. This method returns an array where the 1st term is the CMF indicator for the latest period, the second term of the CMF in the previous period and so on. Please note that the CMF will be evaluated for all periods for which there is sufficient data (see example below for more details).

Note: The form in which the Chaikin Money Flow (CMF) in provided here is particularly suitable when wishing to integrated this functionality within a Client side GUI Charting Application.

Details

Chaikin Money Flow (CMF) is a volume weighted average of Accumulation/Distribution over a specified period, which is usually taken to be 21 days. The CMF offers a volume weighted indicator on the following two principles:

Evaluation

The CMF indicator is evaluated for the following steps:

Example

Within this example we illustrate the way this method works when we consider a given 10 period in which the length of period over which the CHM is evaluated is 4. In this case the result will be an array of 7 elements as follows:

Parameters:
high - an array where the first term in the high in the latest trading period and the second term is the high in the previous trading periods and so on... Until the last term which is the highest market price during the first period which is used in the evaluation of the CMF indicator
low - an array where the first term in the low in the latest trading period and the second term is the low in the previous trading periods and so on... Until the last term which is the lowest market price during the first period which is used in the evaluation of the CMF indicator.
close - an array where the first term is the closing price in the latest trading period and the second term is the closing price in the previous trading periods and so on... Until the last term which is the closing price during the first period which is used in the evaluation of the CMF indicator
volume - an array where the first term in the volume in the securities latest trading period and the second term is the securities volume in the previous trading periods and so on... Until the last term which is the securities volume during the first period which is used in the evaluation of the CMF indicator
lengthOfPeriod - an integer which represents the number of periods over which the indicator is calculated
Returns:
An array where the k-th term corresponds to the Chaikin Money Flow (CMF) indicator on the k-th previous period.
Throws:
IllegalArgumentException - thrown if the arrays high, low, lose, volume do not have the same length or if any element of these arrays is a strictly negative number.
See Also:
chaikinMoneyFlow - evaluates the Chaikin Money Flow for the last period only.

WebCab Technical Analysis
v1.1
(J2SE Edition)