bbgo_origin/pkg/strategy/bollmaker/trend.go

29 lines
539 B
Go
Raw Permalink Normal View History

2022-06-02 18:15:23 +00:00
package bollmaker
import "github.com/c9s/bbgo/pkg/indicator"
type PriceTrend string
const (
NeutralTrend PriceTrend = "neutral"
UpTrend PriceTrend = "upTrend"
DownTrend PriceTrend = "downTrend"
UnknownTrend PriceTrend = "unknown"
)
func detectPriceTrend(inc *indicator.BOLL, price float64) PriceTrend {
if inBetween(price, inc.DownBand.Last(), inc.UpBand.Last()) {
2022-06-02 18:15:23 +00:00
return NeutralTrend
}
if price < inc.LastDownBand() {
return DownTrend
}
if price > inc.LastUpBand() {
return UpTrend
}
return UnknownTrend
}