| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Financial Toolbox |
| Contents | Index |
| Learn more about Financial Toolbox |
output = tsmovavg(tsobj, 's', lag) (Simple) output = tsmovavg(vector, 's', lag, dim) output = tsmovavg(tsobj, 'e', timeperiod) (Exponential) output = tsmovavg(vector, 'e', timeperiod, dim) output = tsmovavg(tsobj, 't', numperiod) (Triangular) output = tsmovavg(vector, 't', numperiod, dim) output = tsmovavg(tsobj, 'w', weights) (Weighted) output = tsmovavg(vector, 'w', weights, dim) output = tsmovavg(tsobj, 'm', numperiod) (Modified) output = tsmovavg(vector, 'm', numperiod, dim)
tsobj | Financial time series object. |
lag | Number of previous data points. |
vector | Row vector or row-oriented matrix. Each row is a set of observations. |
dim | (Optional) Specifies dimension when input is a vector or matrix. Default = 2 (row-oriented matrix: each row is a variable, and each column is an observation). If dim = 1, input is assumed to be a column vector or column-oriented matrix (each column is a variable and each row an observation). output is identical in format to input. |
timeperiod | Length of time period. |
numperiod | Number of periods considered. |
weights | Weights for each element in the window. |
output = tsmovavg(tsobj, 's', lag) and
output = tsmovavg(vector, 's', lag, dim) compute
the simple moving average. lag indicates the number
of previous data points used with the current data point when calculating
the moving average.
output = tsmovavg(tsobj, 'e', timeperiod) and
output = tsmovavg(vector, 'e', timeperiod, dim) compute
the exponential weighted moving average. 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%. (2/(timeperiod
+ 1)).
output = tsmovavg(tsobj, 't', numperiod) and
output = tsmovavg(vector, 't', numperiod, dim) compute
the triangular moving average. 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.
output = tsmovavg(tsobj, 'w', weights) and
output = tsmovavg(vector, 'w', weights, dim) calculate
the weighted moving average 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(tsobj, 'm', numperiod) and
output = tsmovavg(vector, 'm', numperiod, dim) calculate
the modified moving average. 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.
Achelis, Steven B., Technical Analysis from A to Z, Second printing, McGraw-Hill, 1995, pp. 184-192.
![]() | tsmom | typprice | ![]() |
View demos and recorded presentations led by industry experts.
Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |