how to backtest trading strategy???

1 view (last 30 days)
Josh Perry
Josh Perry on 18 Jul 2015
Suppose I have a very simple m file such as:
if true
% code
c=yahoo; d = fetch(c,'xom','Close',now-300,now-1,'d');
fetch(c,'xom','Close',now,now-1,'d');
sd=std(d(:,2));
ma = tsmovavg(d(:,2),'s',90,1);
price = w(1,2);
price
if price<ma-2*sd;
outcome='long';
elseif price>ma+2*sd;
outcome='short';
else outcome='exit';
outcome
close(c)
end
which is obviously messed up. How to I backtest such a trading strategy? Can I do something like this using only matlab or do I have to use MT4 or bloomberg or ...? I need help with this VERY BADLY. Thanks

Answers (0)

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!