Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: movavg   Too many output arguments.
Date: Tue, 2 Oct 2012 03:51:07 +0000 (UTC)
Organization: HSBC
Lines: 40
Message-ID: <k4dobb$m2e$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1349149867 22606 172.30.248.37 (2 Oct 2012 03:51:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 2 Oct 2012 03:51:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2921053
Xref: news.mathworks.com comp.soft-sys.matlab:779661

Here is my code in its entirety:
data = xlsread('brent_1D.xlsx');


filename = 'SBUX.xls';
AllDates = xlsread(filename,'A1:A686')
Close = xlsread(filename,'B1:B686')
annualScaling = sqrt(250);
movavg(Close, 5, 20, 'e')
[Short, Long] = movavg(Close, 5, 20, 'e')


sharpes = nan(100,1);

for m = 1:100
    [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');
end

[~,mxInd] = max(sharpes);
movavg(Close,1,mxInd,annualScaling)
 

Everything works fine up until this line:
    [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');

I get the following error when I run the code through the debugger:
Debugging
1   sharpes = nan(100,1);
Error using movavg
Too many output arguments.

Error in Debugging (line 4)
    [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');


I know the movavg function takes 4 arguments; I can’t tell what the problem is here.  The Editor Window seems somewhat helpful for debugging, but it’s not helping me in the case.

Does anyone have any idea what’s going on here?  Can someone please help me get this straightened out?  Basically, I’ll following the example here:

http://www.mathworks.com/matlabcentral/fileexchange/37932-automated-trading-with-matlab-2012/content/html/Demo2_MA_Rule.html#2