1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Function Max_draw_down(returns As Variant) As Variant
Dim TS As Variant
Dim n As Integer
Dim i As Integer
Dim min As Double
Dim start As Double
Dim difference As Variant
Dim j As Integer
min = 0
TS = returns
i = 0
j = 1
'maximum = TS(1,=max 1)
start = TS(1, 1)
n = TS.Rows.Count
'n = UBound(TS)
For i = 1 To n
'If TS(i + 1, 1) < maximum Then=
Do
For j = i + 1 To n - 1
If start > TS(j + 1, 1) Then
Else
End If
' rang = j
Next j
Loop While start > TS(j + 1, 1)
difference = TS(j + 1, 1) / start - 1
If difference < min Then
min = difference
End If
start = TS(j, 1)
Next i
Max_draw_down = min
End Function |
Partager