add accessors for last up band and down band values

This commit is contained in:
c9s 2020-10-29 19:09:45 +08:00
parent e60127090b
commit 224acd0ca9

View File

@ -20,6 +20,8 @@ Bollinger Bands
Bollinger Bands Technical indicator guide: Bollinger Bands Technical indicator guide:
- https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/bollinger-bands - https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/bollinger-bands
*/ */
//go:generate callbackgen -type BOLL
type BOLL struct { type BOLL struct {
types.IntervalWindow types.IntervalWindow
@ -32,6 +34,16 @@ type BOLL struct {
DownBand Float64Slice DownBand Float64Slice
EndTime time.Time EndTime time.Time
updateCallbacks []func(sma, upBand, downBand float64)
}
func (inc *BOLL) LastUpBand() float64 {
return inc.UpBand[len(inc.UpBand)-1]
}
func (inc *BOLL) LastDownBand() float64 {
return inc.DownBand[len(inc.DownBand)-1]
} }
func (inc *BOLL) LastSMA() float64 { func (inc *BOLL) LastSMA() float64 {