-
Notifications
You must be signed in to change notification settings - Fork 14
/
move.go
56 lines (44 loc) · 946 Bytes
/
move.go
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
48
49
50
51
52
53
54
55
56
package ewa
import "time"
//Duration of the wave
func (m Move) Duration() time.Duration {
return m.End.T.Sub(m.Base.T)
}
//Len - length of the wave
func (m Move) Len() float64 {
if m.Up() {
return m.End.P - m.Base.P
}
return m.Base.P - m.End.P
}
//Up - is wave heading up or down
func (m Move) Up() bool {
return m.End.P > m.Base.P
}
//Retrace - fibonacci retracement
func (m Move) Retrace(level float64) float64 {
if m.Up() {
return m.Base.P + m.Len()*level
}
return m.End.P + m.Len()*level
}
//Begins - time when wave begins
func (m Move) Begins() time.Time {
return m.Base.T
}
//Ends - time when wave ends
func (m Move) Ends() time.Time {
return m.End.T
}
//Starts - price where wave starts
func (m Move) Starts() float64 {
return m.Base.P
}
//Tops - price where wave Tops
func (m Move) Tops() float64 {
return m.End.P
}
//Slope of the wave
func (m Move) Slope() float64 {
return m.Len() / float64(m.Duration())
}