Author: Oscar Cronquist Article last updated on October 29, 2021

How to use the STOCKHISTORY function

The STOCKHISTORY function lets you get stock prices based on a stock quote. It is in the Lookup and reference category and is soon available to Excel 365 subscribers.

The image above shows a dynamic array formula in cell B6:

=STOCKHISTORY(C2, C3, C4, 0, 2, 0, 1, 2, 3, 4, 5)

The function uses the stock quote in specified in cell C2, the start date in cell C3, and the end date in cell C4 to get stock prices.

The formula returns an array of values to cells below and to the right of cell C6.

1. STOCKHISTORY Function Syntax

How to use the STOCKHISTORY function syntax

STOCKHISTORY(stock, start_date, [end_date], [interval], [headers], [property0], [property1], [property2], [property3], [property4], [property5])

Back to top

2. STOCKHISTORY Function Arguments

How to use the STOCKHISTORY function arguments

Argument Text
stock Required. A stock ticker or a reference to a stock ticker.
start_date Required. The first date to start retrieving stock prices for.
[end_date] Optional. The last date to start retrieving stock prices for.
[interval] Optional. Specify the interval.
0 = daily (default)
1 = weekly
2 = monthly
[headers] Optional. Enable header names.
0 = no headers
1 = show headers (default)
2 = show instrument identifier and headers
[property0] Optional. Which columns to show:
0 = Date
1 = Close
2 = Open
3 = High
4 = Low
5 = Volume
[property1] Optional. See [property0] above.
[property2] Optional. See [property0] above.
[property3] Optional. See [property0] above.
[property4] Optional. See [property0] above.
[property5] Optional. See [property0] above.

Back to top

3. How to get daily stock prices in Excel

How to use the STOCKHISTORY function

The STOCKHISTORY function retrieves historical stock prices for a given ticker. You can specify the interval meaning daily, weekly or monthly prices.

The image above demonstrates the STOCKHISTORY function in cell B6, it returns in this example historical daily stock prices for Microsoft between 10/14/2021 and 10/28/2021 specified in cells C3 and C4.

Change the ticker and date range in cells C2:C4 and the function automatically returns data based on the new conditions.

The image above shows a dynamic array formula in cell B6:

=STOCKHISTORY(C2, C3, C4, 0, 2, 0, 1, 2, 3, 4, 5)

The formula above returns header names shown in row 7 as well as the ticker in cell B6. Date, Close, Open, High, Low, and Volume data is returned in this example, however, you can choose the order and what to include using the optional arguments in positions six to eleven.

Back to top

4. How to get weekly stock prices

How to use the STOCKHISTORY function weekly

The image above demonstrates how to return weekly stock prices using the STOCKHISTORY function.

The image above shows a dynamic array formula in cell B6:

=STOCKHISTORY(C2, C3, C4, 1, 2, 0, 1, 2, 3, 4, 5)

Back to top

5. How to get monthly stock prices

How to use the STOCKHISTORY function monthly

The formula above demonstrates how to get monthly stock prices.

Dynamic array formula in cell B6:

=STOCKHISTORY(C2, C3, C4, 2, 2, 0, 1, 2, 3, 4, 5)

Back to top

6. How to get daily closing stock prices

How to use the STOCKHISTORY function closing

The image above shows a dynamic array formula in cell B6:

=STOCKHISTORY(C2, C3, C4, 0, 2, 0, 1)

Back to top

7. How to get volume for a stock quote on a given day

How to use the STOCKHISTORY function volume

The image above demonstrates a formula returning volume data for a stock ticker specified in cell C2.

Dynamic array formula in cell B6:

=STOCKHISTORY(C2, C3, C4, 0, 2, 0, 5)

Back to top

8. How to calculate a moving average

How to use the STOCKHISTORY function average

The image above demonstrates a formula in cell F33 that calculates the average based on the previous 10 days' closing price.

Dynamic array formula in cell B6:

=AVERAGE(C23:C32)

The AVERAGE function calculates the average based on a group of numbers. 10-day, 20 day, 50-day, and 200-day averages are often used to calculate the short trend, medium trend, and long trend direction.

How to plot a moving average on a stock chart

Back to top

9. Get Excel file

Back to top