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
| Function HMA2(Histo(), period As Long)
Dim x As Long, sum1 As Single, sum2 As Single, sum3 As Single, MM1() As Single, MM2() As Single, MM3() As Single
ReDim MM1(LBound(Histo) To UBound(Histo))
ReDim MM2(LBound(Histo) To UBound(Histo))
ReDim MM3(LBound(Histo) To UBound(Histo))
For x = 1 To period \ 2
sum1 = sum1 + Histo(x, 1)
Next
For x = period \ 2 + 1 To period
sum2 = sum2 + Histo(x, 1)
sum3 = sum1 + sum2
MM1(x) = sum3 / (period / 2)
MM2(x) = sum2 / period
MM3(x) = ((2 * MM1(x)) - MM2(x)) / Int(period ^ (1 / 2))
Next
For x = period + 1 To UBound(Histo)
sum2 = sum2 + Histo(x, 1) - Histo(x - (period \ 2), 1)
sum3 = sum3 + Histo(x, 1) - Histo(x - period, 1)
MM1(x) = sum3 / (period / 2)
MM2(x) = sum2 / period
MM3(x) = ((2 * MM1(x)) - MM2(x)) / Int(period ^ (1 / 2))
Next
HMA2 = MM3
End Function |
Partager