From b56e988fc98af42dd9c79376bd30643e07459e00 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 10 Jan 2022 13:49:36 +0800 Subject: [PATCH] support: fix triggerEMA check --- pkg/strategy/support/strategy.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pkg/strategy/support/strategy.go b/pkg/strategy/support/strategy.go index 96237353f..20134db03 100644 --- a/pkg/strategy/support/strategy.go +++ b/pkg/strategy/support/strategy.go @@ -363,14 +363,23 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se return } - s.Notify("Found %s support: the close price %f is below trigger EMA %f and above long term EMA %f and volume %f > minimum volume %f", - s.Symbol, - closePrice.Float64(), - s.triggerEMA.Last(), - s.longTermEMA.Last(), - kline.Volume, - s.MinVolume.Float64(), - kline) + if s.triggerEMA != nil && s.longTermEMA != nil { + s.Notify("Found %s support: the close price %f is below trigger EMA %f and above long term EMA %f and volume %f > minimum volume %f", + s.Symbol, + closePrice.Float64(), + s.triggerEMA.Last(), + s.longTermEMA.Last(), + kline.Volume, + s.MinVolume.Float64(), + kline) + } else { + s.Notify("Found %s support: the close price %f and volume %f > minimum volume %f", + s.Symbol, + closePrice.Float64(), + kline.Volume, + s.MinVolume.Float64(), + kline) + } quantity, err := s.calculateQuantity(session, types.SideTypeBuy, closePrice, kline.Volume) if err != nil {