Skip to content

Instantly share code, notes, and snippets.

@c9s
Forked from austin362667/SharkLong.go
Created September 30, 2022 10:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c9s/8514962865006a5ce641241ad5dcb04c to your computer and use it in GitHub Desktop.
Save c9s/8514962865006a5ce641241ad5dcb04c to your computer and use it in GitHub Desktop.
Harmonic Pattern Strategy: Shark Long
func (s Harmonic) SharkLong(highs, lows *types.Queue, p float64) float64 {
score := 0.
for x := 5; x < 300; x++ {
X := lows.Index(x)
for a := 4; a < x; a++ {
if highs.Index(a-1) < highs.Index(a) && highs.Index(a) > highs.Index(a+1) {
A := highs.Index(a)
XA := math.Abs(X - A)
hB := A - 0.382*XA
lB := A - 0.618*XA
for b := 3; b < a; b++ {
if lows.Index(b-1) > lows.Index(b) && lows.Index(b) < lows.Index(b+1) {
B := lows.Index(b)
if hB > B && B > lB {
//log.Infof("got point B:%f", B)
AB := math.Abs(A - B)
hC := B + 1.618*AB
lC := B + 1.13*AB
for c := 2; c < b; c++ {
if highs.Index(c-1) < highs.Index(c) && highs.Index(c) > highs.Index(c+1) {
C := highs.Index(c)
if hC > C && C > lC {
//log.Infof("got point C:%f", C)
XC := math.Abs(X - C)
hD := C - 0.886*XC
lD := C - 1.13*XC
//for d := 1; d < c; d++ {
//if lows.Index(d-1) > lows.Index(d) && lows.Index(d) < lows.Index(d+1) {
D := p //lows.Index(d)
if hD > D && D > lD {
BC := math.Abs(B - C)
hD2 := C - 1.618*BC
lD2 := C - 2.24*BC
if hD2 > D && D > lD2 {
//log.Infof("got point D:%f", D)
score++
}
}
//}
//}
}
}
}
}
}
}
}
}
}
return score
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment