Add buy and sell points to a stock chart
It is easy to create a stock chart in excel. In this post I am going to describe how to insert buy and sell points.
A 50 day moving average will work as an indicator. If the average changes from negative to positive a buy signal is generated and a sell signal when the average moves from positive to negative trend.
S&P 500
How to quickly import stock prices to an excel sheet? I am using the user defined function from this post:Excel udf: Import historical stock prices from yahoo – added features
It let´s you choose start, end date and interval (daily, weekly, monthly prices).
Select cell range D1:J300 and enter YahooStockQuotes(2009, 9, 1, 2012, 5, 31, "d", "^GSPC") in formula bar. Press and hold Ctrl + Shift. Press Enter.
Calculating moving average
In cell K2:
Copy cell K2 and paste down as far as needed.
Find buy and sell dates
In cell L2:
In cell M2:
Copy cell L2 and M2 and paste down as far as needed.
Extract year and month from date
Let´s extract year and month from dates to avoid a mess in our stock chart. Chandoo has a great post: Show Months & Years in Charts without Cluttering
In cell B2:
In cell B3:
Cell C2:
Copy cell B3 and C2 and paste down as far as needed.
Create stock chart
- Select cell range F1:H300
- Go to tab "Insert"
- Click "Other charts"
- Click "High Low Close stock chart"
Adjust vertical axis min and max values
- Select vertical axis
- Right click on vertical axis
- Click "Format axis..."
- Click "Axis Options"
- Click Minimum fixed and type 1050.
- Click Maximum fixed and type 1450.
Change horizontal axis labels
Reverse horizontal (category) axis
- Select horizontal axis
- Right click on horizontal axis
- Click "Format axis.."
- Click "Axis Options"
- Click "Categories in reverse order"
- Select "Major tick mark type:" None
- Click OK
Add moving average
- Select cell range K1:K300
- Copy
- Select chart
- Got to tab "Home"
- Click "Paste"
- Click "Paste Special.."

- Click "Ok"
- Click on chart
- Go to tab "Format"
- Select "50 day m-avg"

- Click "Format selection"
- Click "Series Options"
- Click "Secondary axis"
- Click "Line color" and select: Solid Line
- Click Close button
Add buy and sell points
- Select cell range L2:L300
- Copy
- Select chart
- Go to tab "Home"
- Click "Paste"
- Click "Paste special"
- Click Ok
Select cell range M2:M300 and repeat above steps.
- Left click on chart
- Go to tab "Format"
- Select "Buy"
- Click "Format Selection"
- Click "Marker Options"
- Click "Bulit-in"
- Select a marker type and size
- Select "Marker Fill"
- Click "Solid Fill"
- Select "Line Color": No line
- Click Close
Repeat above steps with "Sell"
Change secondary vertical axis
- Select and right click on the vertical axis to the left
- Change minimum and maximum values. They must match the primary axis.
- Select and right click on the vertical axis to the right
- Click "Delete"
Add Data Labels
Buy series
- Left click on chart
- Go to tab "Layout"
- Select "Buy" series
- Click "Data Labels"
- Click "More Data Label Options"
- Click "Label options"
- Deselect "Values"
- Select "Series Name"
- Label position: Below
- Click Close
Sell series
- Left click on chart
- Go to tab "Layout"
- Select "Sell" series
- Click "Data Labels"
- Click "More Data Label Options"
- Click "Label options"
- Deselect "Values"
- Select "Series Name"
- Label position: Above
- Click Close
Download excel *.xlsm file
excel stock chart - moving average.xlsm
Related posts:
Plot buy and sell points in an excel chart using two moving averages
Learn how to create a stock chart in excel
Dynamic stock chart in excel – Add date ranges
Adjust stock chart axis automatically
Create a dynamic stock chart using a web query and a drop down list in excel





















