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 Center および File ExchangeFinancial Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by