Maximum Drawdown calculate and plot as a chart

4 ビュー (過去 30 日間)
Mark S
Mark S 2020 年 7 月 11 日
編集済み: Mark S 2020 年 7 月 11 日
Hello, i want create a skript which calculate the drawdown of a stock like this:
I've tried programming something like that but it doesn't worked:
function [] = MAXDRAWDOWN(r)
% Maximum drawdown is defined as the largest drop from a peak to a bottom
% experienced in a certain time period.
% r... vector of returns
% size of r
n = max(size(r));
% calculate vector of cum returns
cr = cumsum(r);
% calculate drawdown vector
classification = zeros( length(r),1 );
for i = 1:n
dd(i) = max(cr(1:i))-cr(i);
classification = dd
Can anybody help me with my project?

回答 (0 件)



Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by