Hi,
I'm new to Matlab and I have been having help to write this code. I am trying to learn on my own and I am trying now to write something that would calculate the highest consecutive negative results in my code. I would be happy to recieve some help!
clear variablesk = 5000;risk = 0.007;riskM = 0.1;maxR = 0.022;numberSteps = 105;markets = zeros(numberSteps,1);markets(1) = k;for i = 1:size(markets,1) - 1 markets(i+1) = markets(i)*(1+0.1); end% ka = 1100
%%
numberSim = 1000;distR = randsrc(numberSteps, numberSim,[-1 -.6 -.36 -.07 0 0.17 0.37 0.39 0.5 0.81 1.37 1.39 1.4 2.2 2.57 3.16 3.55 5.49 6.56 7.34 7.82 8.63 8.7 9.15 9.42 11.55 17.94 19.9 21.18 22.28 28.4 28.51;... .648 .0095 .0095 .0095 0.067 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095]);cumR = cumsum(distR,1);MaxD = maxdrawdown(cumR,'arithmetic');[maxMaxD,ii] = max(MaxD);meanD = mean(MaxD);stdD = std(MaxD); figuresubplot(1,2,1)plot(cumR)subplot(1,2,2)plot(cumR(:,ii))sgtitle(['Mean Drawdown=',num2str(meanD,3),' std=',num2str(stdD,3), ' Max Possible DD=',num2str(maxMaxD,3)])
Best Answer