Skip to content

Commit

Permalink
indicator: fix pivot low indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jul 26, 2022
1 parent 605c665 commit 578e4b2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/indicator/pivot_low.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 578e4b2

Please sign in to comment.