Rank: 163560 based on 0 downloads (last 30 days) and 0 file submitted
photo

Peter

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Peter View all
Updated File Comments Rating
13 Jun 2012 Algorithmic Trading with MATLAB - 2010 Files from the November 18, 2010 webinar. Author: Stuart Kozola

The 2009 version of this has some sample stop code. Fwiw, I haven't found a good array way of doing it, as opposed to looping through the whole period. The biggest drawback being that you cannot use parallel computing.

13 Jun 2012 Technical Indicators A single function that calculates 27 different technical indicators Author: Nate Jensen

Noticed the stochastics delay is calculated using EMA, my TA program calculates it using SMA so there was a slight discrepancy.

09 Jun 2012 Algorithmic Trading with MATLAB - 2010 Files from the November 18, 2010 webinar. Author: Stuart Kozola

Any thoughts on the best way to make this a long/short/flat system, ie you can be 1=long, 0=flat, -1=short? So far you're either long or short, ie always in the market. Any thoughts on what the best way is to run the L/S conditions through the tradesignal file using bit operations?

09 Jun 2012 Algorithmic Trading with MATLAB - 2010 Files from the November 18, 2010 webinar. Author: Stuart Kozola

Interesting approach, still working through this. Bring on the curve fitting!

The tradeSignal.m definitely has a mistake. Couldn't quite get Ivan's solution to work. I fixed it as follows: change to idx = indLoc(:); and add
if (ind2use(iInd)==0) sigC=sigB;
elseif (ind2use(iInd+1)==0) sigC=sigA;

I also renamed some vars and got rid of that eval business, seems to work faster. Full code below, if there are more mistakes feel free to comment.

Re the Sharpe annualization - OMG guys! When you use that Sharpe maximization, you should also realize that you're not really maximizing the Sharpe ratio unless you are working with indexed prices. The PnL function gives prices differences (not returns), Sharpe ratio works with returns!

function sigOut = tradeSignal(pop,ind)
%% BitString Length
cntBString = size(pop,2);

%% Calculate Indicators
% Length = 4*NoIndicators - 2
cntInd = (cntBString+2)/4;
% indicator locations
indLoc = 1:3:cntBString-cntInd;
indLocEnd = max(indLoc);
%% Generate Signal
sigOut = zeros(size(ind,1),size(pop,1));
for iPop = 1:size(pop,1)
ind2use = logical(pop(iPop,cntBString-cntInd+1:end));
idx = indLoc(:);
for iInd = 1:length(idx)-1
% indicator 1
if (iInd == 1) %evaluate first indicator
sigA=[ind(:,iInd)==pop(iPop,idx(iInd))];
else %for all other indicators, combine with the results generated so far
sigA = sigC;
end

% indicator 2
sigB=[ind(:,iInd+1)==pop(iPop,idx(iInd+1))];

% connector
if (ind2use(iInd)==0) sigC=sigB; %I1 inactive
elseif (ind2use(iInd+1)==0) sigC=sigA; %I2 inactive
else
conValue = bin2dec(num2str(pop(iPop,(1:2)+idx(iInd))));
switch conValue
case 0
sigC = bitand(sigA,sigB);
case 1
sigC = bitor(sigA,sigB);
case 2
sigC = bitxor(sigA,sigB);
end
end
end %for
sigOut(:,iPop) = sigC;
end

Contact us