Problem with candle chart and loop

2 ビュー (過去 30 日間)
Dominik
Dominik 2013 年 12 月 24 日
回答済み: the cyclist 2013 年 12 月 24 日
Hello community,
I have a problem with creating a candle chart from a matrix using a for loop.
Just for comparison: I can make a loop for a simple plot (x,y) like this:
for z=1:length(x)
plot(x(1,z),y(1,z),'+r') hold on
end
In this case every point follows each other in the chart and everything is fine.
But when I want to use this simple method with candle() instead of plot(), it just overrides this first candle (data set) in the chart and I get a stack of overlapping candles.
for f=1:length(date)
candle(open(f,4),high(f,3),low(f,5),close(f,2),'b')
hold on
end
Does anybody know how to solve this problem? Would be very nice!
Merry Christmas and thanks, Dominik

回答 (1 件)

the cyclist
the cyclist 2013 年 12 月 24 日
In the version using plot(), you are telling MATLAB to place the plot marker at different x locations, but in the version using candle(), you are not specifying different dates to place the plot markers, so they just overlap. You need to use the 6-argument version of candle(), something like
candle(open(f,4),high(f,3),low(f,5),close(f,2),'b',date(f),Dateform)
as described in the documentation:
doc candle
I don't have the Finance Toolbox, so I may not have that quite right, but I think that is the gist of your problem.

カテゴリ

Help Center および File Exchange2-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