mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
indicator: fix pivot low indicator
This commit is contained in:
parent
605c66556e
commit
578e4b2801
|
@ -21,6 +21,18 @@ type PivotLow struct {
|
||||||
updateCallbacks []func(value float64)
|
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) {
|
func (inc *PivotLow) Update(value float64) {
|
||||||
if len(inc.Lows) == 0 {
|
if len(inc.Lows) == 0 {
|
||||||
inc.SeriesBase.Series = inc
|
inc.SeriesBase.Series = inc
|
||||||
|
@ -53,7 +65,6 @@ func (inc *PivotLow) PushK(k types.KLine) {
|
||||||
inc.EmitUpdate(inc.Last())
|
inc.EmitUpdate(inc.Last())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func calculatePivotLow(lows types.Float64Slice, window int) (float64, error) {
|
func calculatePivotLow(lows types.Float64Slice, window int) (float64, error) {
|
||||||
length := len(lows)
|
length := len(lows)
|
||||||
if length == 0 || length < window {
|
if length == 0 || length < window {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user