+ Reply to Thread
Results 1 to 8 of 8

Calculate maximum drawdown with negative numbers

  1. #1
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Calculate maximum drawdown with negative numbers

    Dear all,

    I've used the macro from a site to calculate the maximum drawdown (a loss due to peak value vs. trough) for positive numbers. The macro can be found here:

    http://investexcel.net/2450/maximum-drawdown-vba/

    Now I've got a problem with this macro, as I need to calculate negative for a sample with both positive and negative numbers. I adapted the formula as:

    temp = (TS(j,1) - TS(i,1)) / abs(TS(i,1))

    But this is not right: a sample with 10, 20, -5, 8 will have a maximum drawdown of -150% using the macro. But the actual maximum drawndown should be: (-5-20)/20 = -125%, which is the loss from the peak 20 to the trough -5.

    Is there any idea to adapt the original macro which is able to do the right calculation when there are negative numbers? I attached the file with macro here.

    Thanks a lot in advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Calculate maximum drawdown with negative numbers

    Will this work:
    Please Login or Register  to view this content.
    Last edited by zbor; 06-11-2013 at 07:53 AM.

  3. #3
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Calculate maximum drawdown with negative numbers

    Hi zbor. Thanks for the code. I noticed that you are comparing the current value i with the previous value i - 1. But the peak value and the trough value may not be necessarily adjacent to each other. For example, a sample of 10, 20, 5, 2 will have a maximum drawdown of 90%: (2-20)/20, while your macro gives a result of -75%. The reason is the peak value 20 and the trough value 2 are not adjacent to each other.


    The idea of the original macro makes sense, but it does not work.

    Quote Originally Posted by zbor View Post
    Will this work:
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Calculate maximum drawdown with negative numbers

    So you actually want this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Calculate maximum drawdown with negative numbers

    Hi, zbor. Thanks for your reply.

    It is not that simple. Because maximum drawdown is defined to be a loss: it must be from the peak value to the trough value. Your formula can be wrong when the trend is actually from trough value to the peak value, which means there is no drawdown.

    As an example, if you bought MicroSoft stock at a price of $100, and today if the price drops to $50, then you made a loss. If the price drops further to $25, then there is a loss again. During this period of time, the maximum drawdown is (25-100)/100 = -75%. If the other way round, if the price is now $125, then there is NO loss at all and the maximum drawdown is 0.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Calculate maximum drawdown with negative numbers

    And if you bought that stock at 100 and price was 125 but now is 110 is that loss or not?

  7. #7
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Calculate maximum drawdown with negative numbers

    Quote Originally Posted by zbor View Post
    And if you bought that stock at 100 and price was 125 but now is 110 is that loss or not?
    Hi zbor, in this case there is a loss in the 2nd time period: (110-125)/125 = -12%

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Calculate maximum drawdown with negative numbers

    You actuall yneed to compare current value with the minimum value of the rest of range.

    I started but don't have time to finnish. Hope it will be rnough for you to figure out solution.
    Attached Files Attached Files

+ 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