Line Weighted Moving Average

A weighted moving average is also designed to put more weight on recent data and less weight on past data. A weighted moving average is calculated by multiplying each of the previous day's data by a weight. The following table shows how a 5-day weighted moving average is calculated.

Day No. Weight * Price = Weighted Price
1 1 25 25
2 2 26 52
3 3 28 84
4 4 25 100
5 5 29 145
Totals 15 133 = 27.067

Note how the 5-day weighted moving average gives five times more weight to today's price (i.e., 5 * 29) than to the price five days ago (i.e., 1* 25).

Syntax:

Public Function LinearWeightedMovAvg(ByVal LWMAIn() As Double, ByVal Lag As Long) As Double

Parameters:

  • ByVal LWMAIn() As Double
  • ByVal Lag As Long

Back to list

 

Example:

 

    Dim TA4Net As New TA4Net.CTAFunctions("YOUR-REGISTRATION-CODE")

    Dim Result() As Double

    Dim CloseValues() As Double

 

    ' loading values to array

    CloseValues = GetCloseValues()

    ' calculating Technical Analysis function

    Result = TA4Net.LineWeightedMovAvg(CloseValues, 14)

 


TA4.NET® Franz AG 2004©
Web site: http://www.ta4.net
e-mail: support@ta4.net

Browser Based Help. Published by chm2web software.