+ Reply to Thread
Results 1 to 10 of 10

Stock price 52 week highs and lows

  1. #1
    Registered User
    Join Date
    11-14-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    5

    Stock price 52 week highs and lows

    Hi,

    I am trying to do some back testing of stock prices looking at 52 week highs and lows.

    I have the standard Yahoo stock data so with date in column A and close in column G.

    I would like to calculate the preceding 52 week high in column H and the 52 week low in column I.

    I found a formula that is almost there for the high:
    =MAX(INDIRECT("G"&MATCH(A2-365,A:A,0)&":"&"G"&ROW()),0)

    But it doesn’t quite work as if A?-365 isn’t a trading day (e.g. weekend) then you get #N/A. I would be happy to use the previous 260 data values (5 days * 52 weeks) as a proxy to calculate the 52 week range.

    I have to say I don’t understand how the formula works and swapping MAX to MIN didn’t work to find the 52 week lows!

    Any help would be much appreciated. Many thanks in advance…

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,155

    Re: Stock price 52 week highs and lows

    Post a sample file.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Stock price 52 week highs and lows

    Maybe something like this...

    =MAX(OFFSET(A2,COUNT(A:A)-1,,-260))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    11-14-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    5

    Re: Stock price 52 week highs and lows

    Hi,

    Sample data set attached. Column H has the 52 Week high formula that almost works - first valid value in H255.

    You can see the #N/A issue - first example in H259.

    Thanks
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,901

    Re: Stock price 52 week highs and lows

    Try ...

    =IFERROR(MAX(INDIRECT("G"&MATCH(A2-365,A:A,0)&":"&"G"&ROW()),0),MAX(INDIRECT("G"&MATCH(A2-365,A:A,1)+1&":"&"G"&ROW()),0))

  6. #6
    Registered User
    Join Date
    11-14-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    5

    Re: Stock price 52 week highs and lows

    Thanks Phuocam - that has solved the problem.

    Is there a way to adapt the formula so that it will calculate the 52 week lows?

    Thanks

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,901

    Re: Stock price 52 week highs and lows

    Change MAX to MIN

  8. #8
    Registered User
    Join Date
    11-14-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    5

    Re: Stock price 52 week highs and lows

    Thanks - I had assumed swapping MAX to MIN would work but that returns 0 for everything rather than the 52 week low

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,901

    Re: Stock price 52 week highs and lows

    Try this:

    =IFERROR(MIN(INDIRECT("G"&MATCH(A2-365,A:A,0)&":"&"G"&ROW())),MIN(INDIRECT("G"&MATCH(A2-365,A:A,1)+1&":"&"G"&ROW())))

  10. #10
    Registered User
    Join Date
    11-14-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    5

    Re: Stock price 52 week highs and lows

    Many thanks - I need to get myself on an advanced Excel course!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Stock list using Vlookup, need the price field to read as TBA is stock on hand is 0
    By meerabell in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-31-2015, 07:42 AM
  2. Total sold price according to stock price list
    By maniootek in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-26-2014, 10:54 PM
  3. Replies: 3
    Last Post: 01-03-2013, 12:32 AM
  4. Finding highs lows for a stock price data (weekly)
    By jayanthkrovi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-22-2012, 03:11 PM
  5. Replies: 0
    Last Post: 10-28-2012, 07:22 AM
  6. How to find a "big jump" or highs/lows in excel?
    By velocio in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-15-2012, 06:57 PM
  7. [SOLVED] Plot Highs and lows?
    By John in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-16-2006, 05:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1