Sunday, June 15, 2008

Creating Market profile with MATLAB


Some Day Traders use CBOT Market Profile for Day Trading purposes. I am NOT a fan of Technical Analysis, but nevertheless, I thought why not write a matlab program to create one.

Here is a quote from CBOT----

Market Profile is a graphical organization of price and time information. Market Profile displays price on the vertical axis and time on the horizontal axis. Letters are used to symbolize time brackets. marketprofile is an analytical decision support tool for traders—not a trading system.


CBOT Overview:




CBOT Examples:



MATLAB CODE:

% clear all
% clc;
% %assuming tick by tick data
% data = load('may01d.mat');
% ESdata = data.ESlast;
ESdata=close;

ESprices=unique(ESdata);
bars=20;
timertick=1;
periods=floor(size(ESdata,1)/(timertick*bars));
MP=zeros(size(ESprices,1),periods);
for i=1:periods
g=ESdata(timertick*bars*(i-1)+1:timertick*bars*i,1);
for m=1:size(g,1)
s=g(m);
s1=find(ESprices==s);
MP(s1,i)=i;
end
end

B = MP;%A(:,2:end) ;
B(B==0) = inf ;
B = sort(B,2) ; % sort each row
B(isinf(B)) = 0 ;

TPO=zeros(size(B));
for l=1:numel(B)
if B(l)~=0
TPO(l)=B(l)+64;
end
end


Final_MP={ESprices char(TPO)};

5 comments:

Anonymous said...

i like your blog.
will bookmark.
keep posting!

meek said...

thank you for sharing your knowledge to every one. I found it worth to me.

Jason Mar said...

Do you have a solution for receiving real time tick data from a feed into matlab? Care to share it?

Specifically, feed name, interface used (C,activeX), db type if any.

Also, I'm curious as to whether one should stream into matlab then store new data to the db, or store data to the db in parallel, and have matlab call from new entries in the db. I would think that having matlab do the storage work would lower the latency. Any thoughts?

aviat72 said...

Do you have a way of displaying the data in a chart? What I am looking for is a market profile like this

http://www.zerohedge.com/sites/default/files/images/SPY%208.24.09-3.jpg

Anonymous said...

If you are not a fan of technical analysis. What kind if analysis do you believe in? When using a computer to analyze trades for you. What else can you use as a gauge to measure a potential trade?

Thanks