Hey,
I have got an Excel worksheet with a lot of stock prices.
I have to calculate the return, the expected return and the standard deviation.
For the expected return and the standard deviation i need to cover 60 days out of 1200 days and have to move on the window - so i start from day 1 to day 60, my next value is 2 to day 61 etc.
My expected return code works, but my standard deviation does not work properly...do you have any ideas for an improvement?
For n = 1 To UBound(St) - 1
return(n) = (St(n, 1) / St(n + 1, 1)) - 1
Next n
'Berechnung des E-Werts'
For i = 1 To 1141
Sum = 0
For n = 1 To 60
Sum = Sum + return(i + n - 1)
Next
WinAve(i, 1) = Sum / 60
Next i
For i = 1 To 1141
SumSq = 0
For n = 1 To 60
SumSq = SumSq + (return(n) - WinAve(i, 1)) ^ 2
StdDev = Sqr(SumSq / (60 - 1))
Next n
WinStd(i, 1) = StdDev
Next i
Bookmarks