Question

I am creating a candlestick chart representing stock prices. Once created, I want to add green circle showing where/when I am buying the stock.

hold on;
candle(myData.High, myData.Low, myData.Close, myData.Open, '', myData.Date, 'dd/mm/yy');
m = plot(myExecutionTable.BuyDate,myExecutionTable.BuyPrice,'og')
uistack(m)
hold off;

The problem is that if myExecutionTable.BuyPrice has a value between the Open and Close, the circle is not showing up. I guess it is hidden under the candlestick. Hence I tried to use uistack but without success. When I change to

plot(myExecutionTable.BuyDate,myExecutionTable.BuyPrice+100,'og')

the green circle then appears (above the candlestick)

Thanks, Serge

Was it helpful?

Solution

The easiest way to make sure one graphics object is on top of another (and not below), is to plot it later.

If for some reason you can't do it this way, you can also manipulate the order of the child objects of the axes:

h = get(gca, 'Children');

returns a vector of graphics handles. Exchange handles between positions in this vector (higher index means higher on top), and then write it back using

set(gca, 'Children', h)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top