Problem with movavg "Not enough input arguments."

3 次查看(过去 30 天)
Hello I am trying to calculate movavg as:
[lead,lag]=movavg(close,5,30);
I have the following:
Error using movavg (line 7) Not enough input arguments.
So if I try:
[lead,lag]=movavg(close,5,30,0);
I have:
Error using movavg (line 8) This function only supports exponential moving averages
So it only works if I use the following:
[lead,lag]=movavg(close,5,30,'e');
...BUT I want simple moving averages not exponential!!
This is strange since the syntax of the function is the following:
movavg(Asset, Lead, Lag, Alpha) [Short, Long] = movavg(Asset, Lead, Lag, Alpha)
Anybody can help me?
  1 个评论
Bruno
Bruno 2014-2-28
编辑:Bruno 2014-2-28
I am wondering if I changed the original function using the files prepared by Stuart Kazola http://www.mathworks.com/matlabcentral/fileexchange/37932-automated-trading-with-matlab-2012
This is the code I have in movavg
function [lead,lag] = movavg(P,M,N,type) %#codegen % moving average, exponentially weighted.
%% % Copyright 2010, The MathWorks, Inc. % All rights reserved. if type ~= 'e' error('MOVAVG:TYPE','This function only supports exponential moving averages') end
L = length(P);
lead = zeros(size(P)); lag = lead;
ws = 2/(M+1); wl = 2/(N+1);
lead(1) = P(1); lag(1) = P(1);
% The for loop approach (slow for small-medium sized data series) for i = 2:L lead(i) = lead(i-1) + ws*(P(i) - lead(i-1)); lag(i) = lag(i-1) + wl*(P(i) - lag(i-1)); end

请先登录,再进行评论。

采纳的回答

Bruno
Bruno 2014-2-28
RESOLVED... the movavg.m prepared by Stuart Kazola conflicts with movavg.m Financial Toolbox R2013b

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by