WebCab Technical Analysis
(J2SE Edition)

webcab.lib.finance.trading.indicators
Class Oscillators

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

public class Oscillators
extends Object
implements Serializable

Within this class we implement Oscillators such as the money flow index, momentum and rate of change (ROC) indicators. Oscillators are generally used to identify short term price reversal points as opposed to longer term trending dynamics.

See Also:
Serialized Form

Constructor Summary
Oscillators()
          Creates a new instance.
 
Method Summary
 double momentum(double closing, double ndayPrice)
          We evaluate the n-day momentum which is simply the difference between today's closing price and the close price n days ago.
 double moneyFlowIndex(double[] high, double[] low, double[] closing, double[] volume)
          Evaluates the Money Flow Index (MFI) measures the strength of money flowing in and out of a security.
 double rateOfChange(double closing, double ndayPrice)
          Calculate the n-day rate of change (ROC) indicator is related to the momentum indicator and will give similar readings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Oscillators

public Oscillators()
Creates a new instance.

Method Detail

moneyFlowIndex

public double moneyFlowIndex(double[] high,
                             double[] low,
                             double[] closing,
                             double[] volume)
Evaluates the Money Flow Index (MFI) measures the strength of money flowing in and out of a security. The MFI is related to the Directional Movement Indicator of Wellas Wilder, but the MFI system also takes into account the volume as well as the price action.

Interpretation
Divergence of the indicator within a continuing trend indicates that a reversal is imminent. The MFI also is a good means to signal market tops and bottoms. A reasonable rule is a market top is given more significance when the MFI is above 80 and a market bottom is given more significance when the MFI is below 20.

Evaluation
The Money Flow Index (MFI) is evaluated over a given user defined number of trading periods. To evaluation of the MFI follows the below steps:

  • Evaluates the Money Flow on each day. The Money Flow is the product of the Typical Value Indicator (see Filters) for that day and the volume.
  • Each day is either classified as either a Positive Money Flow day, Negative Money Flow day or no Flow day. If the typical price increases then the day is a said to be a Positive Money Day, if it decreasing then it is said to be a negative money day and if it stays then same then it is said the be a no flow day.
  • The Positive Money and Negative Money Flow's are calculated by summing the Money Flow over the Positive Money Flow Days or the Negative Money Flow days respectively.
  • The Money Flow Index (MFI) is evaluated by dividing the Positive Money Flow by the Negative Money Flow.
  • Parameters:
    high - an array where the first terms corresponds the trading high on the last trading period, the second term corresponds to the high on the previous trading period and so on. Where the last term corresponds to the highest traded value on the earliest trading period from the period over which the MFI is evaluated.
    low - an array where the first terms corresponds the trading low on the last trading period, the second term corresponds to the low on the previous trading period and so on. Where the last term corresponds to the lowest traded value on the earliest trading period from the period over which the MFI is evaluated.
    closing - an array where the first terms corresponds the closing price on the last trading period, the second term corresponds to the closing price on the previous trading period and so on. Where the last term corresponds to the closing price on the earliest trading period from the period over which the MFI is evaluated.
    volume - an array where the first terms corresponds the volume on the last trading period, the second term corresponds to the volume on the previous trading period and so on. Where the last term corresponds to the volume on the earliest trading period from the period over which the MFI is evaluated.
    Throws:
    IllegalArgumentException - thrown if any of the arrays given as parameters are empty, not equal in length or contain elements which is strictly negative.

    momentum

    public double momentum(double closing,
                           double ndayPrice)
    We evaluate the n-day momentum which is simply the difference between today's closing price and the close price n days ago. The momentum indicator as the name suggests is the velocity with which the price is rising or falling, and hence will reflect how aggressively the asset is being purchased or sold.

    Extended values and/or turning points of the momentum are good indicators of oversold or over brought conditions (respectively).

    Parameters:
    closing - the last closing price of the asset.
    ndayPrice - the closing price of the asset n days ago.
    Throws:
    IllegalArgumentException - thrown if either parameter is strictly negative.

    rateOfChange

    public double rateOfChange(double closing,
                               double ndayPrice)
    Calculate the n-day rate of change (ROC) indicator is related to the momentum indicator and will give similar readings. The (n-day) rate of change (ROC) is just the last closing price divided by the closing price n-days ago.

    As with the case with the momentum indicator the rate of change (ROC) indicator on extended values and/or turning points indicates oversold or over brought conditions (respectively).

    Parameters:
    closing - the last closing price of the asset.
    ndayPrice - the closing price of the asset n days ago.
    Throws:
    IllegalArgumentException - thrown if either parameter is strictly negative.

    WebCab Technical Analysis
    (J2SE Edition)