Problem with candle chart and loop

1 次查看(过去 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 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