lwm_avg()

Aggregate. Returns the linearly weighted moving average for a group of values.

Syntax

lwm_avg ( numeric-expression )

Parameters

numeric-expression

Expressions include integer, long, float, money, timestamp, and interval types.

Usage

The function takes any datatype (except boolean) as its argument, and returns the same datatype. The function places more importance on the most recently received data. NULL values are not included.

An arithmetically weighted average is any average that has multiplying factors that give different weights to different data points based on time sensitivity. In technical analysis, a weighted moving average (WMA) has the specific meaning of weights which decrease arithmetically. In an n-day WMA, the latest day has weight n, the second latest n − 1, and so on, down to zero. The following equation is used to calculate the linear weighted moving average, where pM represents the price of a good on a specific time n.

Moving averages could be used to identify current trends and trend reversals based on closing numbers over a determined period of time. They also could be used to set up support and resistance levels.