Moving average

`tsmovavg`

calculates the simple, exponential,
triangular, weighted, and modified moving average of a vector or `fints`

object
of data. For information on working with financial time series (`fints`

objects)
data, see Working with Financial Time Series Objects.

- example
`output = tsmovavg(tsobj,'s',lag)`

`output = tsmovavg(vector,'s',lag,dim)`

- example
`output = tsmovavg(tsobj,'e',timeperiod)`

`output = tsmovavg(vector,'e',timeperiod,dim)`

- example
`output = tsmovavg(tsobj,'t',numperiod)`

`output = tsmovavg(vector,'t',numperiod,dim)`

- example
`output = tsmovavg(tsobj,'w',weights)`

`output = tsmovavg(vector,'w',weights,dim)`

- example
`output = tsmovavg(tsobj,'m',numperiod)`

`output = tsmovavg(vector,'m',numperiod,dim)`

returns
the exponential weighted moving average for financial time series
object, `output`

= tsmovavg(`tsobj`

,`'e'`

,`timeperiod`

)`tsobj`

. The exponential moving average
is a weighted moving average, where `timeperiod`

specifies
the time period. Exponential moving averages reduce the lag by applying
more weight to recent prices. For example, a 10-period exponential
moving average weights the most recent price by 18.18%. ```
Exponential
Percentage = 2/(TIMEPER + 1) or 2/(WINDOW_SIZE + 1)
```

.

returns
the exponential weighted moving average for a vector. The exponential
moving average is a weighted moving average, where `output`

= tsmovavg(`vector`

,`'e'`

,`timeperiod`

,`dim`

)`timeperiod`

specifies
the time period. Exponential moving averages reduce the lag by applying
more weight to recent prices. For example, a 10-period exponential
moving average weights the most recent price by 18.18%. (```
2/(timeperiod
+ 1)
```

).

returns
the triangular moving average for financial time series object, `output`

= tsmovavg(`tsobj`

,`'t'`

,`numperiod`

)`tsobj`

.
The triangular moving average double-smooths the data. `tsmovavg`

calculates
the first simple moving average with window width of ```
ceil(numperiod
+ 1)/2
```

. Then it calculates a second simple moving average
on the first moving average with the same window size.

returns
the triangular moving average for a vector. The triangular moving
average double-smooths the data. `output`

= tsmovavg(`vector`

,`'t'`

,`numperiod`

,`dim`

)`tsmovavg`

calculates
the first simple moving average with window width of ```
ceil(numperiod
+ 1)/2
```

. Then it calculates a second simple moving average
on the first moving average with the same window size.

returns
the weighted moving average for the financial time series object, `output`

= tsmovavg(`tsobj`

,`'w'`

,`weights`

)`tsobj`

,
by supplying weights for each element in the moving window. The length
of the weight vector determines the size of the window. If larger
weight factors are used for more recent prices and smaller factors
for previous prices, the trend is more responsive to recent changes.

returns
the weighted moving average for the vector by supplying weights for
each element in the moving window. The length of the weight vector
determines the size of the window. If larger weight factors are used
for more recent prices and smaller factors for previous prices, the
trend is more responsive to recent changes.`output`

= tsmovavg(`vector`

,`'w'`

,`weights`

,`dim`

)

returns
the modified moving average for the financial time series object, `output`

= tsmovavg(`tsobj`

,`'m'`

,`numperiod`

)`tsobj`

.
The modified moving average is similar to the simple moving average.
Consider the argument `numperiod`

to be the lag of
the simple moving average. The first modified moving average is calculated
like a simple moving average. Subsequent values are calculated by
adding the new price and subtracting the last average from the resulting
sum.

returns
the modified moving average for the vector. The modified moving average
is similar to the simple moving average. Consider the argument `output`

= tsmovavg(`vector`

,`'m'`

,`numperiod`

,`dim`

)`numperiod`

to
be the lag of the simple moving average. The first modified moving
average is calculated like a simple moving average. Subsequent values
are calculated by adding the new price and subtracting the last average
from the resulting sum.

- Using Time Series to Predict Equity Return
- Data Transformation and Frequency Conversion
- Working with Financial Time Series Objects
- Creating a Financial Time Series Object
- Indexing a Financial Time Series Object
- Financial Time Series Operations
- Using Time Series to Predict Equity Return
- Technical Analysis Examples

Achelis, Steven B. *Technical Analysis from A to Z.* Second
Edition. McGraw-Hill, 1995, pp. 184–192.

`boxcox`

| `convert2sur`

| `convertto`

| `diff`

| `fillts`

| `filter`

| `lagts`

| `leadts`

| `mean`

| `peravg`

| `resamplets`

| `smoothts`

Was this topic helpful?