mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-23 15:25:14 +00:00
indicator: collect pivotlow klines
This commit is contained in:
parent
bea5b27402
commit
892d4cfd1d
|
@ -15,6 +15,8 @@ type PivotLow struct {
|
||||||
|
|
||||||
Lows floats.Slice
|
Lows floats.Slice
|
||||||
Values floats.Slice
|
Values floats.Slice
|
||||||
|
KLines []types.KLine
|
||||||
|
|
||||||
EndTime time.Time
|
EndTime time.Time
|
||||||
|
|
||||||
updateCallbacks []func(value float64)
|
updateCallbacks []func(value float64)
|
||||||
|
@ -32,7 +34,7 @@ func (inc *PivotLow) Last() float64 {
|
||||||
return inc.Values.Last()
|
return inc.Values.Last()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (inc *PivotLow) Update(value float64) {
|
func (inc *PivotLow) update(value float64, k types.KLine) {
|
||||||
if len(inc.Lows) == 0 {
|
if len(inc.Lows) == 0 {
|
||||||
inc.SeriesBase.Series = inc
|
inc.SeriesBase.Series = inc
|
||||||
}
|
}
|
||||||
|
@ -50,6 +52,7 @@ func (inc *PivotLow) Update(value float64) {
|
||||||
|
|
||||||
if low > 0.0 {
|
if low > 0.0 {
|
||||||
inc.Values.Push(low)
|
inc.Values.Push(low)
|
||||||
|
inc.KLines = append(inc.KLines, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +61,7 @@ func (inc *PivotLow) PushK(k types.KLine) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
inc.Update(k.Low.Float64())
|
inc.update(k.Low.Float64(), k)
|
||||||
inc.EndTime = k.EndTime.Time()
|
inc.EndTime = k.EndTime.Time()
|
||||||
inc.EmitUpdate(inc.Last())
|
inc.EmitUpdate(inc.Last())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user