# Problem with movavg "Not enough input arguments."

4 views (last 30 days)
Bruno on 28 Feb 2014
Answered: Bruno on 28 Feb 2014
Hello I am trying to calculate movavg as:
I have the following:
Error using movavg (line 7) Not enough input arguments.
So if I try:
I have:
Error using movavg (line 8) This function only supports exponential moving averages
So it only works if I use the following:
...BUT I want simple moving averages not exponential!!
This is strange since the syntax of the function is the following:
Anybody can help me?

#### 1 Comment

Bruno on 28 Feb 2014
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);
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 on 28 Feb 2014
RESOLVED... the movavg.m prepared by Stuart Kazola conflicts with movavg.m Financial Toolbox R2013b