Skip to content

Commit

Permalink
refactor(indicator): change bollinger band factor type
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-brito committed Jun 9, 2022
1 parent df3caad commit efb5026
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions plot/indicator/bollingerbands.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/markcheno/go-talib"
)

func BollingerBands(period, stdDeviation int, upDnBandColor, midBandColor string) plot.Indicator {
func BollingerBands(period int, stdDeviation float64, upDnBandColor, midBandColor string) plot.Indicator {
return &bollingerBands{
Period: period,
StdDeviation: stdDeviation,
Expand All @@ -21,7 +21,7 @@ func BollingerBands(period, stdDeviation int, upDnBandColor, midBandColor string

type bollingerBands struct {
Period int
StdDeviation int
StdDeviation float64
UpDnBandColor string
MidBandColor string
UpperBand model.Series
Expand All @@ -43,9 +43,7 @@ func (bb *bollingerBands) Load(dataframe *model.Dataframe) {
return
}

deviation := float64(bb.StdDeviation)

upper, mid, lower := talib.BBands(dataframe.Close, bb.Period, deviation, deviation, talib.EMA)
upper, mid, lower := talib.BBands(dataframe.Close, bb.Period, bb.StdDeviation, bb.StdDeviation, talib.EMA)
bb.UpperBand, bb.MiddleBand, bb.LowerBand = upper[bb.Period:], mid[bb.Period:], lower[bb.Period:]

bb.Time = dataframe.Time[bb.Period:]
Expand Down

0 comments on commit efb5026

Please sign in to comment.