+ Reply to Thread
Results 1 to 9 of 9

Relative Strength Formula in Excel 2007

Hybrid View

  1. #1
    Registered User
    Join Date
    09-16-2011
    Location
    Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    30

    Relative Strength Formula in Excel 2007

    Hi All,

    Trying to use excel to backtest momentum stock strategies in excel. I have all of the raw data and need some help putting the formulas together. I am probably making it sound more difficult than it is, but here is the objective:

    "Purchase" the stock with the highest trailing returns. To mimic this purchase, we must first identify the highest value in I8:P8. Then, we must reflect only the % change in value for the stock with the highest relative strength. To do so, we need to calculate the change from row 8 to row 9 and so on. The percent gain/loss will be multiplied by a hypothetical starting value of a portfolio that invests in the strategy (cell not shown on the sample sheet, but it would be a single cell with a starting value of 1, for example).

    For example, in the attached spreadsheet the highest value in I8:P8 is K8. Therefore, I want to only purchase Stock C using the value in C8 as the entry price and hold until the price in C9. The % gain/loss between c8/c9 would be multiplied by the starting value of the portfolio (not shown on the sheet). Then, repeat this calculation for each subsequent row.
    Attached Files Attached Files
    Last edited by oyz79; 12-03-2012 at 11:23 PM.

  2. #2
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Relative Strength Formula in Excel 2007

    Sorry, I didn't open the workbook, as I have a couple too many open atm, But in C8 '=Max(I8:P8)' will give you the highest Value of the range..

    I'll close some workbooks down and load yours up
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  3. #3
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Relative Strength Formula in Excel 2007

    Okay, without some examples of what you expect to see in the cells, this is what I came up with
    Formula: copy to clipboard

    =IF(MAX($I8:$P8)=I8,((MAX($I8:$P8)-OFFSET($J$8,1,MATCH(MAX($I8:$P8),$I8:$P8,0)))/100)*1,"")


    if stock a is highest, subtract next stock a from it, divide by 100 for percent change, multiply by "1"(hypothetical starting value) and display, else leave blank

    Drag down and across

    Hope this helps
    Last edited by dredwolf; 12-04-2012 at 12:31 AM. Reason: Missed a set of brackets

  4. #4
    Registered User
    Join Date
    09-16-2011
    Location
    Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Relative Strength Formula in Excel 2007

    sample book.xlsxI have adjusted my sample workbook. Column Q is what I'm primarily concerned with automating and I added the formulas manually for an example, however, in the interest of time (there are several hundred rows on my actual sheet) I don't want to manually adjust the formula every time. Columns I through P probably aren't necessary since they are based on the values in A through H, but I put them there to help flush out my idea.

  5. #5
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Relative Strength Formula in Excel 2007

    Okay, the question I have is : Is the basic formula I described above near the formula you are looking for? or am I completely off track here?

  6. #6
    Registered User
    Join Date
    09-16-2011
    Location
    Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Relative Strength Formula in Excel 2007

    I can't get the formula to work - are there additional inputs I need to add?

    I'm primarily interested in focusing column Q, the new sample workbook should provide a good example of how I want the formula to adjust each new row based on the values in A-H and I-P (I-P is probably redundant since its just based on the values in A-H). The key is to automate the formula, rather than manually adjust it.

  7. #7
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Relative Strength Formula in Excel 2007

    The cell referencing may have to be changed, which is one of the reasons I asked if I was on the the right track with how I described it, if the premise I used to create the formula is wrong, then there is no sense in using it


    if stock a is highest, subtract next stock a from it, divide by 100 for percent change, multiply by "1"(hypothetical starting value) and display, else leave blank

    Hmmm...guess quote tags don't work this way...lol :D...edit- fixed them
    Last edited by dredwolf; 12-04-2012 at 01:10 AM.

  8. #8
    Registered User
    Join Date
    09-16-2011
    Location
    Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Relative Strength Formula in Excel 2007

    It might be easier to forget I-P and try this, in plain english: Calculate (A7-A1)/A1, calculate (B7-B1)/B1, calculate (C7-c1)/c1 etc. through column H. For the highest single value-- let's assume its (B7-B1)/B1) in this example-- then calculate only (b8-b7/b7).


    If I can get this formula in a separate row, then have the ability to repeat it each row I would be a happy man.

    If I were to do this manually, it might look like =(Q6*(1+(B8-B7)/B7)), but I am having to manually change the (B8-B7/B7), the goal is to automate it.

    Thanks for your help

  9. #9
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Relative Strength Formula in Excel 2007

    if you have the formula you want for your first row, you should be able to enter it, then highlight the cell, move cursor to lower right of cell till you see the '+', click And hold, drag down till you reach the end of the range..this is the method used by many contributors to this forum, as the actual cell references will change to meet the new cell they are in- only one caveat, the $ sign in front of any Column letter OR Row number will lock the reference to that Column/Row...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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