Azzera filtri
Azzera filtri

Maximum Drawdown calculate and plot as a chart

7 visualizzazioni (ultimi 30 giorni)
Mark S
Mark S il 11 Lug 2020
Modificato: Mark S il 11 Lug 2020
Hello, i want create a skript which calculate the drawdown of a stock like this: https://twitter.com/charliebilello/status/1126104370012131328
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.
%
% INPUTS:
% 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
end
end
Can anybody help me with my project?

Risposte (0)

Categorie

Scopri di più su Downloads in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by