LinearlyWeightedMovingAverage(SeriesCollection,Int32) Method
Returns the value of the Linearly Weighted Moving Average (LWMA) for all periods for which sufficient historical data is provided.
Syntax
'Declaration Public Overloads Shared Function LinearlyWeightedMovingAverage( _ ByVal sc As SeriesCollection, _ ByVal lengthOfMA As Integer _ ) As SeriesCollection
'Usage Dim sc As SeriesCollection Dim lengthOfMA As Integer Dim value As SeriesCollection value = StatisticalEngine.LinearlyWeightedMovingAverage(sc, lengthOfMA)
public static SeriesCollection LinearlyWeightedMovingAverage( SeriesCollection sc, int lengthOfMA )
Parameters
- sc
- A collection of series objects. For example, to evaluate this indicator for two series you will need to pass a series collection containing this two series.
- lengthOfMA
- The number of periods over which the moving average is evaluated for each period.
Return Value
A series where the first term is the LWMA of length
lengthOfMA
for the latest period, the second term is the LWMA of length lengthOfMA
for the previous period and so on.Exceptions
Exception | Description |
---|---|
System.ArgumentException | Thrown if the series s is empty or if its length
is less than the lengthofMA . |
Remarks
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 and so on... Until the weight of the most recent value is assigned to be the parameter
lengthOfMA
, after which the LWMA is given by the sum of the weighted prices divided by the sum of the weights. This indicator then shifts the window (one place back) over which the MA is evaluated and the indicator is then re-evaluated.Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also