필터 지우기
필터 지우기

How to add time information to candlestick chart?

조회 수: 6 (최근 30일)
Çağlar  İŞLEK
Çağlar İŞLEK 2021년 1월 31일
댓글: Çağlar İŞLEK 2021년 2월 14일
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
Siddharth Bhutiya 2021년 2월 8일
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