From 224acd0ca9e89816314ff0e8db8ff8dfc443eea5 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 29 Oct 2020 19:09:45 +0800 Subject: [PATCH] add accessors for last up band and down band values --- pkg/indicator/boll.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/indicator/boll.go b/pkg/indicator/boll.go index 5301a97d1..0206a46c8 100644 --- a/pkg/indicator/boll.go +++ b/pkg/indicator/boll.go @@ -20,6 +20,8 @@ Bollinger Bands Bollinger Bands Technical indicator guide: - https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/bollinger-bands */ + +//go:generate callbackgen -type BOLL type BOLL struct { types.IntervalWindow @@ -32,6 +34,16 @@ type BOLL struct { DownBand Float64Slice 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 {