Hallo,
einen kleinen Schritt bin ich wohl weiter gekommen ;-)
Letztendlich muß wohl Anke ran......
VBS
1. Parameter: daten, datenreihe, close
2. Parameter alpha, wert, 0.7
StartI = ErsteDatenPeriode(Daten)
EndI = LetzteDatenPeriode(Daten)
Dim myArray(4), a(4), Median
Dim Smooth,Cycle,Q1,I1,InPhase,DeltaPhase,MedianDelta,DC,InstPeriod,Period,I2,Q2
ReDim Smooth(EndI),Cycle(EndI),Q1(EndI),I1(EndI),InstPeriod(EndI),DeltaPhase(EndI),MedianDelta(EndI),DC(EndI),Period(EndI)
For i = StartI + 7 To EndI
Smooth(i) = (Daten(i) + 2*Daten(i-1) + 2*Daten(i-2) + Daten(i-3)) / 3
Cycle(i) = (1-0.5*alpha)*(1-0.5*alpha)*(smooth(i)-2*Smooth(i-1)+Smooth(i-2))+2*(1-alpha)*cycle(i-1)-(1-alpha)*(1-alpha)*cycle(i-2)
Q1(i) = (0.962*Cycle(i) + 0.5769*Cycle(i-2) - 0.5769*Cycle(i-4) - 0.962*Cycle(i-6)) * (0.5 + 0.8*InstPeriod(i-1))
I1(i) = Cycle(i-3)
IF Q1(i) <> 0 and Q1(i-1) <> 0 Then
DeltaPhase(i) = (I1(i) / Q1(i) - I1(i-1) / Q1(i-1)) / (1 + I1(i)*I1(i-1) / (Q1(i)*Q1(i-1)))
End If
IF DeltaPhase(i) < 0.1 Then
DeltaPhase(i) = 0.1
End If
If DeltaPhase(i) > 1.1 Then
DeltaPhase(i) = 1.1
End If
myArray(0) = DeltaPhase(i)
myArray(1) = DeltaPhase(i-1)
myArray(2) = DeltaPhase(i-2)
myArray(3) = DeltaPhase(i-3)
myArray(4) = DeltaPhase(i-4)
a(0) = myArray(0)
a(1) = myArray(1)
a(2) = myArray(2)
a(3) = myArray(3)
a(4) = myArray(4)
BubbleSort(myArray)
MedianDelta(i) = Median
IF MedianDelta(i) = 0 Then
DC = 15
else DC = 6.28318 / MedianDelta(i) + 0.5
End If
'InstPeriod(i) = 0.33*DC + 0.67*InstPeriod(i-1)
'Period(i) = 0.15*InstPeriod(i) + 0.85*Period(i-1)
Ergebnis(i) = DC 'Period(i)
Next
Function BubbleSort(myArray)
Dim i, n, Temp
Dim Sortiert
n = UBound(a)
Do
Sortiert = True
For i = 0 To n - 1
If a(i) > a(i + 1) Then
Temp = a(i)
a(i) = a(i + 1)
a(i + 1) = Temp
Sortiert = False
End If
Next
Loop Until Sortiert
BubbleSort = a
Median = a(2)
End Function