# 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:

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.

### What's on this page

- STOCKHISTORY function syntax
- STOCKHISTORY function arguments
- How to get daily historical stock prices in Excel
- How to get weekly historical stock prices
- How to get historical monthly stock prices
- How to get historical closing stock prices
- How to get volume for a stock quote on a given day
- How to calculate a moving average
- Get Excel file

## 1. STOCKHISTORY Function Syntax

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

## 2. 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. |

## 3. How to get daily stock prices in Excel

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:

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.

## 4. How to get weekly stock prices

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:

## 5. How to get monthly stock prices

The formula above demonstrates how to get monthly stock prices.

Dynamic array formula in cell B6:

## 6. How to get daily closing stock prices

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

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

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

Dynamic array formula in cell B6:

## 8. How to calculate a moving 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:

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

## 9. Get Excel file

### Useful links

STOCKHISTORY function - Microsoft

### 'STOCKHISTORY' function examples

The following article has a formula that contains the STOCKHISTORY function.

This stock chart built in Excel allows you to change the date range and the chart is instantly updated. What's […]

### Functions in 'Lookup and reference' category

The STOCKHISTORY function function is one of 25 functions in the 'Lookup and reference' category.

## How to comment

How to add a formula to your comment<code>Insert your formula here.</code>

Convert less than and larger than signsUse html character entities instead of less than and larger than signs.

< becomes < and > becomes >

How to add VBA code to your comment[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

How to add a picture to your comment:Upload picture to postimage.org or imgur

Paste image link to your comment.

Contact OscarYou can contact me through this contact form