# How to use the STOCKHISTORY function

**What is 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 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

## 1. Introduction

**What are stocks?**

Stocks or equities represent ownership in a company. When you buy a stock you buy a small portion of that company's assets and profits. Stocks are traded on stock exchanges, such as the New York Stock Exchange (NYSE) or NASDAQ, and their prices can fluctuate based on various market and economic factors.

**What are historical stock prices?**

Historical stock prices refer to the past prices of a stock over a specific period of time. These prices can be used to analyze the stock's performance, identify trends, and make informed investment decisions.

**Can you plot historical stock prices in Excel?**

Yes, you can plot historical stock prices in Excel. Get historical stock prices using the STOCKHISTORY function, then plot the prices. You have four stock chart options:

- High-Low-Close chart
- Open-High-Low-Close chart
- Volume-High-Low-Close chart
- Volume-High-Low-Close chart

Here is how:

- Select the range containing the data points.
- Go to tab "Insert" on the ribbon.
- Press with mouse on "Recommended charts" button. A dialog box appears.
- Go to tab "All charts" located on the dialog box.
- Press with left mouse button on the "Stock" category.
- Pick a stock chart.

A more detailed demonstration is here: How to create a stock chart

**What is a moving average?**

A moving average is a statistical calculation that takes the average of a set of data points over a specific period of time. In the context of stock prices a moving average is a calculation that takes the average of a stock's price over a certain number of days, weeks, or months. The average is then plotted on a chart, and the line is "moving" because it is constantly being updated as new data points are added.

**What is technical analysis?**

Technical stock analysis is a method of evaluating a stock's potential for future price movements based on its past price and volume data. Technical analysts use charts and other tools to identify patterns and trends in a stock's price movement and to make predictions about future price movements. Technical analysis is based on the idea that a stock's price reflects all publicly available information about the company and that by analyzing the price movement an analyst can gain insights into the stock's future potential. Technical analysts use a variety of tools and techniques including charts, trend lines, and indicators, to analyze a stock's price movement and make predictions.

**What is fundamental analysis?**

Fundamental stock analysis, on the other hand is a method of evaluating a stock's potential for future price movements based on the company's underlying financial performance. Fundamental analysts examine a company's financial statements, management team, industry trends, and competitive position to estimate its future earnings and cash flow. Fundamental analysts use a variety of tools and techniques, including financial ratios, industry analysis, and competitive analysis, to evaluate a stock's potential.

## 2. Syntax

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

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