Problem with candle chart and loop
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
the cyclist
on 24 Dec 2013
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.
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!