2022-09-01 04:09:03 +00:00
|
|
|
package elliottwave
|
|
|
|
|
|
|
|
import "github.com/c9s/bbgo/pkg/indicator"
|
|
|
|
|
|
|
|
type ElliottWave struct {
|
|
|
|
maSlow *indicator.SMA
|
|
|
|
maQuick *indicator.SMA
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ElliottWave) Index(i int) float64 {
|
2023-05-31 23:46:50 +00:00
|
|
|
return s.Last(i)
|
2022-09-01 04:09:03 +00:00
|
|
|
}
|
|
|
|
|
2023-05-31 23:46:50 +00:00
|
|
|
func (s *ElliottWave) Last(i int) float64 {
|
|
|
|
return s.maQuick.Index(i)/s.maSlow.Index(i) - 1.0
|
2022-09-01 04:09:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ElliottWave) Length() int {
|
|
|
|
return s.maSlow.Length()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ElliottWave) Update(v float64) {
|
|
|
|
s.maSlow.Update(v)
|
|
|
|
s.maQuick.Update(v)
|
|
|
|
}
|