+ Reply to Thread
Results 1 to 7 of 7

Trading an equity curve's slope

  1. #1
    Registered User
    Join Date
    01-25-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2002
    Posts
    5

    Trading an equity curve's slope

    First post here.
    I'm building and automatic trading system (ATS) and have a spreadsheet which lists the trades taken based on a set of trading rules. An equity curve is also generated which sometimes shows long periods of wins and losses (on average). I only want to trade when the equity curve is rising. The format of the spreadsheet looks like this:

    Trade # Type Net Profit - *** NP

    1 Buy ($25.00)
    Sell ($25.00)
    2 Buy $112.50
    Sell $87.50
    3 Buy $12.50
    Sell $100.00
    4 Sell Short $0.00
    Buy to Cover $100.00
    5 Sell Short ($37.50)
    Buy to Cover $62.50
    6 Buy $0.00
    Sell $62.50
    7 Sell Short ($25.00)
    Buy to Cover $37.50

    Now I want to calculate the average of the *** profit over the last X trades. But, as you can see the *** profit is listed on every other line. So I guess I need some way to make this calculation but skip the input value every other line.

    Now part 2 is performing a check to see if the line connecting this rolling average is positive or negative. If its negative, then stop trading, and don't add the net profit for the trades to the ***. profit until the slope turns positive again.

    I've attached a picture of the equity curve for reference.

    I'm getting stuck on how to calculate an average on a Column of numbers, but skipping every other row. I can't change the formate of what's initially give to me above. Any help is appreciated.
    Thanks in advance.
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    01-25-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2002
    Posts
    5
    Ok, so the *** is supposed to be "cumulative".

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please post a workbook and explain in context.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    01-25-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2002
    Posts
    5

    Re: Trading an equity curve's slope

    OK, attached is a workbook with text explaining what I'm trying to do. Again, skipping every other row when doing calculations, to me, is the hard part.
    Thanks in advance.
    Attached Files Attached Files

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Trading an equity curve's slope

    To compute the average of every other row starting with row C6,

    =AVERAGE(IF(MOD(ROW(C6:C18) - ROW(C6), 2) = 0, C6:C18) )

    This is an array formula, meaning it MUST be confirmed with Ctrl+Shift+Enter, not just Enter. (With the cursor in the formula bar, hold down Ctrl and Shift, then press Enter.) You'll know you did it correctly if curly braces appear around the formula in the Formula Bar; you cannot type in the braces directly.

  6. #6
    Registered User
    Join Date
    01-25-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2002
    Posts
    5

    Re: Trading an equity curve's slope

    Thanks SHG,
    Now that looks like it will average the values in Column D correct? I had to manually cut and past those values from Column C, which would be crazy if I had thousands of rows. Is there and automatic way to skip rows when averaging. Also, I need a moving average of say the last 10 rows, so a fixed value of C6:c18 won't work. How can I make it a moving average?
    Thanks again.

  7. #7
    Registered User
    Join Date
    01-25-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2002
    Posts
    5

    Re: Trading an equity curve's slope

    Never mind that last post SHG, your code worked great. Now how can I vary the range over which the moving average is calculated via an input in say cell A5?
    I'll try playing around with the OFFSet function I just found.
    Thanks in advance.

+ 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