17.05 - Simple Moving Average - Teradata Database

Teradata Vantage™ - Advanced SQL Engine Analytic Functions

prodname
Advanced SQL Engine
Teradata Database
vrm_release
17.00
17.05
created_date
June 2020
category
Programming Reference
featnum
B035-1206-170K

The simple moving average (SMA) is the unweighted mean of the previous n data points. For example, a 10-day simple moving average of closing price is the mean of closing prices for the previous 10 days.

With MAvgType ('S'), the MovingAverage function uses this procedure:
  1. Compute the arithmetic average of the first window_size rows.

    The value window_size is specified by the WindowSize syntax element. In the next step, it is called N.

  2. For each subsequent row, compute the new simple moving average value with this formula:

    SMA = (V1+V2+...+VN)/N

    Vi is the value of the target column at index i in the window.