|
Sub calmtommy()
Dim arr, brr(), crr(), drr()
Dim i%, j%, k%, r%
arr = Sheet1.[a1].CurrentRegion
For i = 3 To UBound(arr) - 1
If arr(i + 1, 3) < arr(i, 3) And arr(i - 1, 3) < arr(i, 3) Then
j = j + 1
ReDim Preserve brr(1 To j)
brr(j) = arr(i, 3)
End If
If arr(i, 3) < arr(i + 1, 3) And arr(i, 3) < arr(i - 1, 3) Then
k = k + 1
ReDim Preserve crr(1 To k)
crr(k) = arr(i, 3)
End If
Next i
r = Application.WorksheetFunction.Min(j, k)
For i = 1 To r
ReDim Preserve drr(i)
drr(i) = (crr(i) - brr(i)) / brr(i)
Next i
MsgBox "最大回撤为:" & Application.WorksheetFunction.Max(drr)
End Sub |
|