%% Calculate Maximum Drawdown
% Calculate the maximum drawdown (MaxDD) using example data with a fund, market, and cash series:

load FundMarketCash
MaxDD = maxdrawdown(TestData)

% The maximum drop in the given time period was 16.58% for the fund series, and 33.81% for the market series. There was no decline in the cash series, as expected, because the cash account never loses value.
% Copyright 2018 The MathWorks, Inc.