Code covered by the BSD License  

Highlights from
Automated Trading with MATLAB - 2012

image thumbnail

Automated Trading with MATLAB - 2012

by

 

31 Aug 2012 (Updated )

Files from the Automated Trading webinar showing X_Trader and QuickFIX/J integration.

ruleChartMA(YMatrix1, YMatrix2, sh)
function ruleChartMA(YMatrix1, YMatrix2, sh)
%CREATEFIGURE(YMATRIX1,YMATRIX2)
%  YMATRIX1:  matrix of y data
%  YMATRIX2:  matrix of y data

%  Auto-generated by MATLAB on 08-Mar-2011 10:55:35
%  Small customizations also performed to make a dynamic title and linked
%  axes.

% Create figure
figure1 = figure;

% Create subplot
subplot1 = subplot(2,1,1,'Parent',figure1,'YGrid','on','XGrid','on');
box(subplot1,'on');
hold(subplot1,'all');

% Create multiple lines using matrix input to plot
plot1 = plot(YMatrix1,'Parent',subplot1);
set(plot1(1),'DisplayName','Close');
set(plot1(2),'DisplayName','Lead');
set(plot1(3),'DisplayName','Lag');

% Create title
title(['First pass results: Annual Sharpe ratio = ', num2str(sh,3)]);

% Create subplot
subplot2 = subplot(2,1,2,'Parent',figure1,'YGrid','on','XGrid','on');
box(subplot2,'on');
hold(subplot2,'all');

% Create multiple lines using matrix input to plot
plot2 = plot(YMatrix2,'Parent',subplot2);
set(plot2(1),'DisplayName','Position');
set(plot2(2),'DisplayName','Cumulative return');

% Create legend
legend1 = legend(subplot1,'show');
set(legend1,'Location','Best');

% Create legend
legend2 = legend(subplot2,'show');
set(legend2,'Location','Best');

% Create xlabels
xlabel(subplot1, 'Serial day number');
xlabel(subplot2, 'Serial day number');

% Create ylabels
ylabel(subplot1, 'Price ($)');
ylabel(subplot2, 'Returns ($)');

linkaxes([subplot1, subplot2],'x')

Contact us