From 578e4b2801ed0510f637003b4cc2a749e7ca0360 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 27 Jul 2022 00:58:05 +0800 Subject: [PATCH] indicator: fix pivot low indicator --- pkg/indicator/pivot_low.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/indicator/pivot_low.go b/pkg/indicator/pivot_low.go index d47b60f31..cdcbb4890 100644 --- a/pkg/indicator/pivot_low.go +++ b/pkg/indicator/pivot_low.go @@ -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 {