Borrar filtros
Borrar filtros

How to add time information to candlestick chart?

6 visualizaciones (últimos 30 días)
Çağlar  İŞLEK
Çağlar İŞLEK el 31 de En. de 2021
Comentada: Çağlar İŞLEK el 14 de Feb. de 2021
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 comentarios
Siddharth Bhutiya
Siddharth Bhutiya el 8 de Feb. de 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.
Çağlar  İŞLEK
Çağlar İŞLEK el 14 de Feb. de 2021
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:

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by