WebCab Technical Analysis
(J2EE Edition)

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

All Superinterfaces:
EJBObject, Remote

public interface MovingAverage
extends EJBObject

Moving Averages in there various forms are used to smooth data so that the underlying trend is more discernible. Since a moving average's aim is to recognize a trending market from historical prices the sensitivity of the measures will depend on the number of a historical values used. For relatively few values used the moving average may itself oscillate rapidly and give many force signals to the start of trending markets. If many values are used fewer force signals will be generated but a trend may in well into its cycle before it is detected and conversely when the trend finishes or changes direction the indicator will take correspondingly longer the reflect this.

With the construction of the moving averages themselves the main significant difference between them is the weight assigned to each price point. Simple moving averages apply equal weight to all historical prices. Exponential and weighted averages apply more weight to recent prices. Triangular averages apply more weight to prices in the middle of the time period and variable moving averages change the weighting based on the volatility of prices.

Interpretation
When the moving average us higher than the asset price then the asset is in a bearish trend (i.e. trending down) and when the asset is above the moving average then the asset is in a bullish trend (i.e. trending up-wards).

Moving Averages are also used in pairs and even triples. When using a pair of moving averages of the same type where one moving average uses fewer days and hence is more sensitive, the underlying asset is said to be in bullish mode if the moving average using the fewer number of days crosses above the less sensitive moving average which is using more days data. Conversely, if the less sensitive moving average cross above the more sensitive moving average then asset is said to be in a bearish mode.

All moving averages are lagging indicators and hence will miss the first part of a trend and over-run the same trend. There is also a play-off is the number of historical days use which determines the sensitivity of the indicator.


Method Summary
 double exponentiallyWeightedMovingAverage(double[] timeSeries, double smoothingFactor)
          We evaluate the Exponentially Weighted Moving Average (EWMA) of a time series from the 0 th period until the t th period.
 double geometricMovingAverage(double[] historicalValue)
          The Geometric Moving Average (GMA) is the geometric average of the values given over the past x days.
 double linearlyWeightedMovingAverage(double[] priceSeries)
          This method returns the value of the Linearly Weighted Moving Average (LWMA) of a (finite) price series.
 double medianMovingAverage(double[] historicalHigh, double[] historicalLow)
          Returns the Median Moving Average.
 double simpleMovingAverage(double[] historicalPrice)
          The x-day moving average is the arithmetic average of the market price of a traded asset over the past x-days.
 double weightedxDayMovingAverage(double[] historicalPrices, double[] weights)
          Here we evaluate the Weighted Moving Average (WMA) which allows you to assign more significance to resent price dynamics.
 
Methods inherited from interface javax.ejb.EJBObject
getEJBHome, getHandle, getPrimaryKey, isIdentical, remove
 

Method Detail

simpleMovingAverage

public double simpleMovingAverage(double[] historicalPrice)
                           throws RemoteException
The x-day moving average is the arithmetic average of the market price of a traded asset over the past x-days. Clearly, the price on each of these days should be sampled in a consistent manor. For example, the moving average could take the average close prices on the last x-days in order to evaluate the average.

Parameters:
historicalPrice - an array of length x, where the first element historicalPrice[0], corresponds to the market price on the first of the x-day period. The term historicalPrice[1], corresponds to the market price of the second of the x-day period, and so on...
Throws:
IllegalArgumentException - thrown if the historicalPrices array is empty.
RemoteException

medianMovingAverage

public double medianMovingAverage(double[] historicalHigh,
                                  double[] historicalLow)
                           throws RemoteException
Returns the Median Moving Average.

Parameters:
historicalHigh - an array where the first element historicalHigh[0], corresponds to the highest market price during the last trading period, the historicalHigh[1], corresponds to the highest market price in the previous period, and so on..
historicalLow - an array where the first element historicalLow[0], corresponds to the lowest market price during the last trading period, the historicalLow[1], corresponds to the lowest market price in the previous period, and so on...
Throws:
IllegalArgumentException - thrown if the arrays historicalHigh and historicalLow are of different lengths or if one of these arrays is empty.
RemoteException

geometricMovingAverage

public double geometricMovingAverage(double[] historicalValue)
                              throws RemoteException
The Geometric Moving Average (GMA) is the geometric average of the values given over the past x days. This indicator is particularly appropriate in the study of time series of values which obey the logarithm addition law. One such example is a series of the returns of an asset over a number of periods.

Parameters:
historicalValue - an array of length x, where the first element historicalPrice[0], corresponds to the market on the first of the x-day period. The term historicalPrice[1], corresponds to the market price of the second of the x-day period, and so on...
Throws:
IllegalArgumentException - thrown if the historicalValue array is empty.
RemoteException

weightedxDayMovingAverage

public double weightedxDayMovingAverage(double[] historicalPrices,
                                        double[] weights)
                                 throws RemoteException
Here we evaluate the Weighted Moving Average (WMA) which allows you to assign more significance to resent price dynamics.

Parameters:
weights - this is an array of length x, which assigns to each of the historicalPrices a weighting. The ith element weights[i], assigns to the element historicalPrice[i], a weighting.
historicalPrices - an array of length x, where the first element historicalPrice[0], corresponds to the market on the first of the x-day period. The term historicalPrice[1], corresponds to the market price of the second of the x-day period, and so on.
Throws:
IllegalArgumentException - thrown if the length of the weights and historicalPrices arrays differ or if either array is empty.
RemoteException
See Also:
xDayMovingAverage

linearlyWeightedMovingAverage

public double linearlyWeightedMovingAverage(double[] priceSeries)
                                     throws RemoteException
This method returns the value of the Linearly Weighted Moving Average (LWMA) of a (finite) price series. The Linearly Weighted Moving Average (LWMA) weights the time series by assigning a weight of 1, to the oldest price and a weight of 2 to the second oldest price on so on... Until the weight of the most recent value is assigned to be the number of days in the time series. Then the LWMA is given by the sum of the weighted prices divided by the sum of the weights.

Parameters:
priceSeries - an array where the first element is the price on the earliest day, the second element is the price on the next earliest day and on so.
Throws:
IllegalArgumentException - thrown if the array priceSeries is empty.
RemoteException

exponentiallyWeightedMovingAverage

public double exponentiallyWeightedMovingAverage(double[] timeSeries,
                                                 double smoothingFactor)
                                          throws RemoteException
We evaluate the Exponentially Weighted Moving Average (EWMA) of a time series from the 0 th period until the t th period.

Parameters:
timeSeries - an array where the first value corresponds to the value of the asset in the $t$th period, and the second value corresponds to the value of the asset in the $t-1$th period and so on
Throws:
IllegalArgumentException - thrown if the timeSeries is empty or if the value given for the smoothing factor lies outside the closed range [0,1].
RemoteException

WebCab Technical Analysis
(J2EE Edition)