indicator: fix pivot low indicator

This commit is contained in:
c9s 2022-07-27 00:58:05 +08:00
parent 605c66556e
commit 578e4b2801
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -21,6 +21,18 @@ type PivotLow struct {
updateCallbacks []func(value float64)
}
func (inc *PivotLow) Length() int {
return inc.Values.Length()
}
func (inc *PivotLow) Last() float64 {
if len(inc.Values) == 0 {
return 0.0
}
return inc.Values.Last()
}
func (inc *PivotLow) Update(value float64) {
if len(inc.Lows) == 0 {
inc.SeriesBase.Series = inc
@ -53,7 +65,6 @@ func (inc *PivotLow) PushK(k types.KLine) {
inc.EmitUpdate(inc.Last())
}
func calculatePivotLow(lows types.Float64Slice, window int) (float64, error) {
length := len(lows)
if length == 0 || length < window {