How to plot a candlestick chart
3 views (last 30 days)
Show older comments
Hi,
I have a .csv file which contains stock information of Amazon e.g. date(30/10/2013), closePrice(361.08), volume(4500014), openPrice(362.62), highPrice(365), lowPrice(358.65). So there are about 2517 rows and 6 columns. First i want to read data from .csv file then plot a candlestick chart. So I have loaded my .csv file like this:
clear;
close all;
fid = fopen('Amazon.csv');
HDRS = textscan(fid,'%s %s %s %s %s %s',1, 'delimiter',',');
DATA = textscan(fid,'%s %f %f %f %f %f','delimiter',',');
fclose(fid);
outCell = cell(size(DATA{1},1), length(HDRS));
for i = 1:length(HDRS);
if isnumeric(DATA{i});
outCell(:,i) = num2cell(DATA{i});
else
outCell(:,i) = DATA{i};
end
end
candle (outCell{:,5}, outCell{:,6}, outCell{:,2}, outCell{:,4}, 'b', outCell{:,1});
but when running the file i get an error saying: Error using candle Too many input arguments. can someone help me i am sure matlab can read 2517X6 set of data to plot candlestick chart.
Thanks.
2 Comments
Answers (1)
Walter Roberson
on 18 Nov 2013
MATLAB Coder (the product you indicated you are using) is not able to generate code for anything involving graphics: it is only suitable for generating C or C++ code for numeric routines. MATLAB Coder is also, if I recall, unable to generate code when cell arrays are used.
The problems you would observe would be different than the message you indicate you saw, as the code generation process would fail long before you were able to run a call to candle()
The simplest explanation is that you are not using the MATLAB Coder product.
3 Comments
See Also
Categories
Find more on Data Import and Analysis 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!