Adding to a graph of stock prices

조회 수: 1 (최근 30일)
P_Alpha
P_Alpha 2015년 10월 16일
댓글: P_Alpha 2015년 10월 17일
Hi Everyone,
I have a graph with dates on the x axis and stock prices on the y axis. I have the closing price and moving average being plotted here. I have a variable with dates in col 1 and the change in the stock price in col 2. I would like to plot a circle on the the stock price line when the percent change is greater than .02. Any advice would be appreciated as I am at a complete loss. Best

답변 (1개)

Image Analyst
Image Analyst 2015년 10월 17일
To get the percent change in stock price, you need the stock price itself, not just the change in stock price. Assuming you have that and can get the dates and percent changes into 1-D vectors, you can do:
indexes = percentChanges > 0.02;
hold on;
plot(dates(indexes), percent(indexes), 'ro', 'MarkerSize', 16, 'LineWidth', 2);
  댓글 수: 1
P_Alpha
P_Alpha 2015년 10월 17일
This kind of gets me what I am looking for. My issue now is that is screw with my axis limits, and I would like to plot them on the line "Stock Prices". My current plot of just stock prices is something along the lines of:
plot(pricedates,tickeradJclose,'-r')
I now also have have the logical that identifies when the price change is over .02 so I am not really sure how to get this to fall on onto my price line. Thanks so much for the help so far!

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

카테고리

Help CenterFile Exchange에서 Financial Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by