I found the following way to do this:
Firstly, I observed that you need date in the column vector format and not a cell
. Only way to achieve that is to convert date into some numerical representation. That's exactly what datenum
does. Example as follows:
DateString = '11/12/2013';
formatIn = 'mm/dd/yyyy';
datenum(DateString,formatIn)
ans =
735550
Convert all your dates in this format. Next, I feel that if you construct the time series object, it would be much easier to plot as shown here. This needs a financial time series object to work. No problem. It can be constructed as shown here. In this case, I believe it can be constructed as (dummy example):
dates={'11/12/2013';'11/13/2013'}
higPrice=[100;100]
lowPrice=[10;10]
closePrice=[90;80]
openPrice=[80;70]
%construct a financial time series object
tsobj = fints(datenum(dates,formatIn), [higPrice lowPrice closePrice openPrice], {'high','low','close','open'}) %put in correct order
candle(tsobj); %I get the plot
EDIT: I forgot to mention that if I try to give any other names than 'high','low','open','close'
it doesn't work. For example, I tried with 'highPrice','lowPrice','openPrice','closePrice'
. I do not know the reason for this as I am also using candle
for the first time.