WebCab Technical Analysis
v1.1
(J2SE Edition)

webcab.lib.finance.trading.indicators
Class Volume

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

public class Volume
extends Object
implements Serializable

Indicators such Negative/Positive Trading Index and On Balance Volume which describe the effects of volume on the price dynamics.

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
Volume()
          Creates a new instance.
 
Method Summary
 double[] negativeVolumeIndex(double[] closes, double[] volumes)
          Implements the Negative Volume Index (NVI) as introduced by Norman Fosback.
 double[] onBalanceVolume(double[] volumes)
          Implements the On Balance Volume (OBV) indicator which was introduced by Joe Granville within this book New Strategy of Daily Stock Market Timing for Maximum Profits.
 double[] positiveVolumeIndex(double[] closes, double[] volumes)
          Implements the Positive Volume Index (PVI) as introduced by Norman Fosback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Volume

public Volume()
Creates a new instance.

Method Detail

negativeVolumeIndex

public double[] negativeVolumeIndex(double[] closes,
                                    double[] volumes)
Implements the Negative Volume Index (NVI) as introduced by Norman Fosback.

Evaluation

The procedure used for the evaluation of this indicator is as follows:

  1. For any period where the volume is less then the previous periods volume the NVI is evaluated using the formula:

    NVI = (Previous Periods NVI) + ( ( (Close - (Previous Close) ) / (Previous Close) ) * (Previous NVI) )

  2. If the volume is greater than or equal to the previous periods volume then:

    NVI = Yesterday's NVI

Parameters:
closes - an array of the trading closing prices over the last n-periods where the k-th terms of the array if the closing price on the k-th previous period.
volumes - an array of the trading volumes over the last n-periods where the k-th terms of the array if the trading volume on the k-th previous period.
Returns:
Returns an array where the first element will be a value of the most recent period considered, and the second element will be the value of the previous period and so on.
Throws:
IllegalArgumentException - thrown if either parameter is strictly negative or arrays closes or volumes are empty.

positiveVolumeIndex

public double[] positiveVolumeIndex(double[] closes,
                                    double[] volumes)
Implements the Positive Volume Index (PVI) as introduced by Norman Fosback.

Indicator Evaluation

The procedure used for the evaluation of this indicator is as follows:

  1. For any period where the volume is greater than the previous periods volume the PVI is evaluated using the formula:

    PVI = (Previous Periods PVI) + ( ( (Close - Previous Close) / (Previous Close) ) * Previous PVI)

  2. If the present periods volume is less than or equal to the previous periods volume then we have:

    PVI = Previous Periods PVI

Parameters:
closes - an array of the trading closing prices over the last n-periods where the k-th terms of the array if the closing price on the k-th previous period.
volumes - an array of the trading volumes over the last n-periods where the k-th terms of the array if the trading volume on the k-th previous period.
Returns:
Returns an array where the first element will be a value of the most recent period considered, and the second element will be the value of the previous period and so on.
Throws:
IllegalArgumentException - thrown if either parameter is strictly negative or arrays closes or volumes are empty.

onBalanceVolume

public double[] onBalanceVolume(double[] volumes)
Implements the On Balance Volume (OBV) indicator which was introduced by Joe Granville within this book New Strategy of Daily Stock Market Timing for Maximum Profits. The indicator relates the volume to changes in the price and rests on the assumption that OBV changes precede price changes.

Evaluation Procedure

The OBV indicator is evaluated in accordance with the following rules:

  1. If the present periods closing price is greater than the previous periods close then:

    OBV = Previous OBV + Present Volume

  2. If the present periods closing price is less than the previous periods close then:

    OBV = Previous periods OBV - Present Volume

  3. If the present periods closing price is equal to the previous close then:

    OBV = Yesterday's OBV

Parameters:
volumes - an array of the trading volumes over the last n-periods where the k-th terms of the array if the trading volume on the k-th previous period.
Returns:
Double value of the On Balance Volume for the last n-periods volume for the asset considered.
Throws:
IllegalArgumentException - thrown if either parameter is strictly negative or arrays volumes is empty.

WebCab Technical Analysis
v1.1
(J2SE Edition)