The drawdown is the measure of the decline from a historical peak in some variable (typically the cumulative profit or total open equity of a financial trading strategy). Somewhat more formally, if is a stochastic process with , the drawdown at time , denoted , is defined as:The average drawdown (AvDD) up to time is the time average of drawdowns that have occurred up to time :The maximum drawdown (MDD) up to time is the maximum of the drawdown over the history of the variable. More formally, the MDD is defined as: Pseudocode The following pseudocode computes the Drawdown ("DD") and Max Drawdown ("MDD") of the variable "NAV", the Net Asset Value of an investment. Drawdown and Max Drawdown are calculated as percentages: MDD = 0 peak = -99999 for i = 1 to N step 1 do # peak will be the maximum value seen so far (0 to i), only get updated when higher NAV is seen if (NAV[i] > peak) then peak = NAV[i] end if DD[i] = 100.0 × (peak - NAV[i]) / peak # Same idea as peak variable, MDD keeps track of the maximum drawdown so far. Only get updated when higher DD is seen. if (DD[i] > MDD) then MDD = DD[i] end if end for Trading definitions There are two main definitions of a drawdown: 1. How low it goes (the magnitude) Put plainly, a drawdown is the “pain” period experienced by an investor between a peak (new highs) and subsequent valley (a low point before moving higher) in the value of an investment. The Maximum Drawdown, more commonly referred to as Max DD, is the worst (the maximum) peak to valley loss since the investment’s inception. In finance, the use of the maximum drawdown as an indicator of risk is particularly popular in the world of commodity trading advisors through the widespread use of three performance measures: the Calmar ratio, the Sterling ratio and the Burke ratio. These measures can be considered as a modification of the Sharpe ratio in the sense that the numerator is always the excess of mean returns over the risk-free rate while the standard deviation of returns in the denominator is replaced by some function of the drawdown. 2. How long it lasts (the duration) The drawdown duration is the length of any peak to peak period, or the time between new equity highs. The max