Problem with movavg "Not enough input arguments."

조회 수: 3 (최근 30일)
Bruno
Bruno 2014년 2월 28일
답변: Bruno 2014년 2월 28일
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