Author: Oscar Cronquist Article last updated on September 04, 2019

The image above shows an Excel chart of the S&P 500 with buy and sell signals based on a 50 day average.

It is easy to create a stock chart in Excel. In this article, I am going to describe how to insert buy and sell points to an Excel chart.

To simplify things I will use a 50 day moving average as an indicator. If the 50day average changes from negative to positive a buy signal is generated and a sell signal when the average moves from positive to a negative trend.

I have copied stock data from the Yahoo Finance website, you can easily pick a stock or index and get historical data.

Calculating moving average

The AVERAGE function calculates the moving average, remember to use the last 50 days as an argument. I am using a relative cell reference that changes accordingly when the cell is copied to cells below.

In cell K2:

=AVERAGE(H2:H51)

Copy cell K2 and paste down as far as needed.

Find buy and sell dates

The following formulas check if the 50-day average is higher or lower than the previous day and the day before that, this will return the close value only if there is a change in trend.

In other words multiple buy or sell signals won't be displayed, only the first one. The first IF function has two logical expressions (K2-K3>0) and (K3-K4<0), both these conditions must be true to return the value in K2.

In cell L2:

=IF((K2-K3>0)*(K3-K4<0), K2, "")

In cell M2:

=IF((K2-K3<0)*(K3-K4>0), K2*1, "")

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 on the x axis in our stock chart. The YEAR function returns the year based on an Excel date.

Chandoo has a great post: Show Months & Years in Charts without Cluttering

In cell B2:

=YEAR(D2)

In cell B3:

=IF(YEAR(D3)=YEAR(D2), "", YEAR(D3))

The TEXT function formats an Excel date in this particular example, and displays the month formatted with only first three visible characters.

The IF function makes sure that the formatted month name is shown only when the month changes, this to avoid repeated months.

Cell C2:

=IF(TEXT(D2, "MMM")=TEXT(D3, "MMM"), "", TEXT(D2, "MMM"))

Copy cell B3 and C2 and paste down as far as needed.

Create stock chart

It is important that the data is arranged in this order: High, Low and Close.

  1. Select cell range F1:H300
  2. Go to tab "Insert"
  3. Press with left mouse button on "Other charts"
  4. Press with left mouse button on "High Low Close stock chart"

Adjust vertical axis min and max values

If your chart is zoomed out too far you can simply adjust the visible axis range by following these steps.

  1. Select vertical axis
  2. Press with right mouse button on on vertical axis
  3. Press with left mouse button on "Format axis..."
  4. Press with left mouse button on "Axis Options"
  5. Press with left mouse button on Minimum fixed and type 1050.
  6. Press with left mouse button on Maximum fixed and type 1450.

Change horizontal axis labels

These steps change the x-axis numbers to years and months based on the values in column B and C.

  1. Press with right mouse button on on chart
  2. Press with left mouse button on "Select data"
  3. Press with left mouse button on "Edit" button
  4. Select cell range B2:C300
  5. Press with left mouse button on OK

Reverse horizontal (category) axis

If the dates are backward then these steps tell you how to change the order.

  1. Select horizontal axis
  2. Press with right mouse button on on horizontal axis
  3. Press with left mouse button on "Format axis.."
  4. Press with left mouse button on "Axis Options"
  5. Press with left mouse button on "Categories in reverse order"
  6. Select "Major tick mark type:" None
  7. Press with left mouse button on OK

Add moving average

These steps explains how to display the moving average on an Excel chart.

  1. Select cell range K1:K300
  2. Copy
  3. Select chart
  4. Got to tab "Home"
  5. Press with left mouse button on "Paste"
  6. Press with left mouse button on "Paste Special.."
  7. Press with left mouse button on "Ok"
  8. Press with mouse on chart
  9. Go to tab "Format"
  10. Select "50 day m-avg"
  11. Press with left mouse button on "Format selection"
  12. Press with left mouse button on "Series Options"
  13. Press with left mouse button on "Secondary axis"
  14. Press with left mouse button on "Line color" and select: Solid Line
  15. Press with left mouse button on Close button

 How to display buy and sell signals on an Excel chart?

  1. Select cell range L2:L300
  2. Copy
  3. Select chart
  4. Go to tab "Home"
  5. Press with left mouse button on "Paste"
  6. Press with left mouse button on "Paste special"
  7. Press with left mouse button on Ok

Select cell range M2:M300 and repeat above steps.

  1. Press with left mouse button on on chart to select it
  2. Go to tab "Format"
  3. Select "Buy"
  4. Press with left mouse button on "Format Selection"
  5. Press with left mouse button on "Marker Options"
  6. Press with left mouse button on "Bulit-in"
  7. Select a marker type and size
  8. Select "Marker Fill"
  9. Press with left mouse button on "Solid Fill"
  10. Select "Line Color": No line
  11. Press with left mouse button on Close

Repeat above steps with "Sell"

Change secondary vertical axis

  1. Select and press with right mouse button on on the vertical axis to the left
  2. Change minimum and maximum values. They must match the primary axis.
  3. Select and press with right mouse button on on the vertical axis to the right
  4. Press with left mouse button on "Delete"

Add Data Labels

Buy series

  1. Press with left mouse button on on chart to select it
  2. Go to tab "Layout"
  3. Select "Buy" series
  4. Press with left mouse button on "Data Labels"
  5. Press with left mouse button on "More Data Label Options"
  6. Press with left mouse button on "Label options"
  7. Deselect "Values"
  8. Select "Series Name"
  9. Label position: Below
  10. Press with left mouse button on Close

Sell series

  1. Press with left mouse button on on chart to select it
  2. Go to tab "Layout"
  3. Select "Sell" series
  4. Press with left mouse button on "Data Labels"
  5. Press with left mouse button on "More Data Label Options"
  6. Press with left mouse button on "Label options"
  7. Deselect "Values"
  8. Select "Series Name"
  9. Label position: Above
  10. Press with left mouse button on Close