NDK_WMA

int __stdcall NDK_WMA ( double *  pData,
size_t  nSize,
BOOL  bAscending,
double *  weights,
size_t  nwSize,
int  nHorizon,
double *  retVal 
)

Returns the weighted moving (rolling/running) average using the previous m data points.

Returns
status code of the operation
Return values
NDK_SUCCESS  Operation successful
NDK_FAILED  Operation unsuccessful. See Macros for full list.
Parameters
[in] pData  is the univariate time series data (a one dimensional array).
[in] nSize  is the number of elements in pData.
[in] bAscending  is the time order in the data series (i.e. the first data point's corresponding date (earliest date=1 (default), latest date=0)).
[in] weights  is the size of the equal-weighted window or an array of multiplying factors (i.e. weights) of the moving/rolling window.
[in] nwSize  is the number of elements in the weights array.
[in] nHorizon  is the forecast time/horizon beyond the end of pData. If missing, a default value of 0 (Latest or end of pData) is assumed.
[out] retVal  is the calculated value of the weighted moving average.
Remarks
  1. The time series is homogeneous or equally spaced.
  2. The time series may include missing values (NaN) at either end.
  3. The window size (m) must be less than the time series size, or else an error value (#VALUE!) is returned.
  4. The weights array should have a size greater than zero and consist of non-negative values.
  5. The size argument must match the actual size of the passed weight array, or else an error value (#VALUE) is returned.
  6. The weighted moving average in Excel (WMA) is defined as: \[ \mathit{wma}_t^k=\frac{\sum_{i=0}^{k-1} x_{t-k+i}\times w_i}{\sum_{i=0}^{k-1} w_i}\] Where:
    • \(w_i\) is the weight of the i-th data point in the moving/rolling window.
    • \(k\) is the size of the moving/rolling window.
    • \(x_t\) is the value of the time series at time t.
  7. IMPORTANT: The first value in the weights array corresponds to the earliest point in the MA window.
  8. IMPORTANT: To exclude current observation from the moving average in Excel, set the last value (weight) in the given array to zero.
  9. The size of the weighted moving averqage time series is equal to the input time series.
Requirements
Header SFSDK.H
Library SFSDK.LIB
DLL SFSDK.DLL
Examples


   
Namespace:  NumXLAPI
Class:  SFSDK
Scope:  Public
Lifetime:  Static
int NDK_WMA ( double[]  pData,
int  nSize,
BOOL  bAscending,
double[]  pWeights,
int  nwSize,
int  nHorizon,
ref double  retVal 
)

Returns the weighted moving (rolling/running) average using the previous m data points.

Returns
status code of the operation
Return values
NDK_SUCCESS  Operation successful
NDK_FAILED  Operation unsuccessful. See Macros for full list.
Parameters
[in] pData  is the univariate time series data (a one dimensional array).
[in] nSize  is the number of elements in pData.
[in] bAscending  is the time order in the data series (i.e. the first data point's corresponding date (earliest date=1 (default), latest date=0)).
[in] pWeights  is the size of the equal-weighted window or an array of multiplying factors (i.e. weights) of the moving/rolling window.
[in] nwSize  is the number of elements in the weights array.
[in] nHorizon  is the forecast time/horizon beyond the end of pData. If missing, a default value of 0 (Latest or end of pData) is assumed.
[out] retVal  is the calculated value of the weighted moving average.
Remarks
  1. The time series is homogeneous or equally spaced.
  2. The time series may include missing values (NaN) at either end.
  3. The window size (m) must be less than the time series size, or else an error value (#VALUE!) is returned.
  4. The weights array should have a size greater than zero and consist of non-negative values.
  5. The size argument must match the actual size of the passed weight array, or else an error value (#VALUE) is returned.
  6. The weighted moving average in Excel (WMA) is defined as: \[ \mathit{wma}_t^k=\frac{\sum_{i=0}^{k-1} x_{t-k+i}\times w_i}{\sum_{i=0}^{k-1} w_i}\] Where:
    • \(w_i\) is the weight of the i-th data point in the moving/rolling window.
    • \(k\) is the size of the moving/rolling window.
    • \(x_t\) is the value of the time series at time t.
  7. IMPORTANT: The first value in the weights array corresponds to the earliest point in the MA window.
  8. IMPORTANT: To exclude current observation from the moving average in Excel, set the last value (weight) in the given array to zero.
  9. The size of the weighted moving averqage time series is equal to the input time series.
Exceptions
Exception Type Condition
None N/A
Requirements
Namespace NumXLAPI
Class SFSDK
Scope Public
Lifetime Static
Package NumXLAPI.DLL
Examples

	
References
* Hamilton, J .D.; Time Series Analysis , Princeton University Press (1994), ISBN 0-691-04289-6
* Tsay, Ruey S.; Analysis of Financial Time Series John Wiley & SONS. (2005), ISBN 0-471-690740
* D. S.G. Pollock; Handbook of Time Series Analysis, Signal Processing, and Dynamics; Academic Press; Har/Cdr edition(Nov 17, 1999), ISBN: 125609906
* Box, Jenkins and Reisel; Time Series Analysis: Forecasting and Control; John Wiley & SONS.; 4th edition(Jun 30, 2008), ISBN: 470272848