File Exchange

image thumbnail

Candlestick Graph

version 1.0.0.0 (472 Bytes) by Nagi Hatoum
Plots a candlestick graph.

9 Downloads

Updated 06 Jun 2003

No License

This a candlestick graph function. It is an improvement over the one in MATLAB 5.2. It draws the colors correctly and can be included in subplots.

Comments and Ratings (9)

Nicky

SSOI SS

Hi I made update for you to speed up. Old codes are too slow for large amount of data ....

%%%%%%%%draw line from Low to High%%%%%%%%%%%%%%%%%
% ------------ following codes too slow ------- %
% lineHandles = zeros(1,l);
% for i=1:l
% lineHandles(i) = line([date(i) date(i)],[L(i) H(i)],'Color',colorLine);
% end
% --------------------------------------------- %

lineDataX = zeros(1,3*l);
lineDataY = zeros(1,3*l);

lineDataX(1:3:end) = date;
lineDataX(2:3:end) = date;
lineDataX(3:3:end) = NaN;

lineDataY(1:3:end) = L;
lineDataY(2:3:end) = H;
lineDataY(3:3:end) = NaN;

lineHandles = plot(lineDataX, lineDataY, 'Color', colorLine);

%%%%%%%%%%draw white (or user defined) body (down day)%%%%%
% ------------ following codes too slow ------- %
% fill1Handles = zeros(1,length(n));
% for i=1:length(n)
% x=[date(n(i))-w date(n(i))-w date(n(i))+w date(n(i))+w date(n(i))-w];
% y=[O(n(i)) C(n(i)) C(n(i)) O(n(i)) O(n(i))];
% fill1Handles(i) = fill(x,y,colorDown);
% end
% --------------------------------------------- %

n=find(d<0);
x=[date(n)-w date(n)-w date(n)+w date(n)+w];
y=[O(n) C(n) C(n) O(n)];
z=ones(size(x));
fill1Handles = patch(x', y', z', 'FaceColor', colorDown);

%%%%%%%%%%draw black (or user defined) body(up day)%%%%%%%
% ------------ following codes too slow ------- %
% n=find(d>=0);
% fill2Handles = zeros(1,length(n));
% for i=1:length(n)
% x=[date(n(i))-w date(n(i))-w date(n(i))+w date(n(i))+w date(n(i))-w];
% y=[O(n(i)) C(n(i)) C(n(i)) O(n(i)) O(n(i))];
% fill2Handles(i) = fill(x,y,colorUp);
% end
% --------------------------------------------- %

n=find(d>=0);
x=[date(n)-w date(n)-w date(n)+w date(n)+w];
y=[O(n) C(n) C(n) O(n)];
z=ones(size(x));
fill2Handles = patch(x', y', z', 'FaceColor', colorUp);

DE YAO

Great!

Michele Denber

Brian O'Donnell

Exactly what I need!

Tyler Moore

Awesome

Yiwen Yang

Excellen! Thank you very much.

ESAS sas

Good. Congratulations.

William Bain

Great! I love it!

MATLAB Release Compatibility
Created with R10
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: Bar- and candle style graph for stocks