How to add time information to candlestick chart?

6 次查看(过去 30 天)
Hello,
I have below code to chart candlesticks for financial data, I created a timetable, TT, and tried to skecth candle sticks but output figure is not correct, I cannot see sticks, only candle appears. Instead of timetable, if I tried to plot with a matrix without time information, results look good but without time. How to add time information to candlestick chart?
[a,b,c]=xlsread('202001.csv');
load('priceM1_2020.mat');
time=datetime(c(:,1));
Open=priceM1_2020(1:31652,1);
High=priceM1_2020(1:31652,2);
Low=priceM1_2020(1:31652,3),
Close=priceM1_2020(1:31652,4);
TT=timetable(time,Open,High,Low,Close);
candle(TT(end-50:end,:))
Result with timetable input;
Results with matrix(double) input;
  3 个评论
Siddharth Bhutiya
I tried plotting both the data as timetable and as a double and I am getting the same plot for both the cases. Can you share the double matrix that is generating the candlesticks graph you showed above.
candle(TT(end-50:end,:)) % Plot using timetable input
mat = TT{end-50:end,:}; % Extract the data from the timetable into a matrix
candle(mat) % Plot using matrix input
On a side note, it would be better to use readtable instead of xlsread to read your csv file into MATLAB.
Çağlar  İŞLEK
Çağlar İŞLEK 2021-2-14
Thank you for responses, below are the additional information and answers to your questions.
I tried this on both r2020a and r2019a and got same results.
The source of data is attached. "trial.csv".
Below is 2 trials, frist one tried to plot from original file. Second one, keep only time, open, high, low, close values in the table. Both methods output same result. Stil I dont have time information on the plot.
Trial-1
TT=readtable('trial.csv');
candle(TT(end-50:end,:))
Trial-2
TT=readtable('trial.csv');
TT(:,1)=[];
TT(:,1)=[];
TT(:,6)=[];
candle(TT(end-50:end,:))
Result:

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by