How to add time information to candlestick chart?
5 views (last 30 days)
Show older comments
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 Comments
Siddharth Bhutiya
on 8 Feb 2021
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.
Answers (0)
See Also
Categories
Find more on Data Preprocessing 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!