How to draw candle with dates?

조회 수: 7 (최근 30일)
Avi Michaely
Avi Michaely 2018년 9월 21일
이동: DGM 2024년 1월 7일
Hello, I'm trying to create a candle chart with dates at the X axis, but it only shows index numbers. This is my code:
function createCandle(tbl, dateStart, dateEnd)
tbl(tbl.Date<datetime(dateStart,'InputFormat','dd/MM/yyyy'),:)=[]; %Delete what's befor start date
tbl(tbl.Date>datetime(dateEnd,'InputFormat','dd/MM/yyyy'),:)=[]; %Delete what's after end date
candle(tbl);
I call it like this:
createCandle('DAX_Index_Candle.xlsx', '21/02/2016', '13/03/2017');
Table is attached.
This is what I'm getting:
As you see in the bottom there's numbers which I'm guessing are index numbers for the samples, but not the dates from the table.

채택된 답변

Greg
Greg 2018년 9월 21일
First, your function cannot work with the example provided. You pass a filename then use it as a table or timetable variable. Please provide the full code.
Otherwise, assuming you're using a straightforward read operation on the file, it is almost certainly returning a table. Simply use table2timetable and then plot that with candle.
  댓글 수: 3
Ruby Singh
Ruby Singh 2019년 1월 8일
easiest fix ever!
thank you
Sinan Islam
Sinan Islam 2024년 1월 7일
When I plot using timetable, the candle function plots empty spaces between bars in random locations.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by