support: fix triggerEMA check

This commit is contained in:
c9s 2022-01-10 13:49:36 +08:00
parent 2d4ce2d41c
commit b56e988fc9

View File

@ -363,14 +363,23 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
return 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", if s.triggerEMA != nil && s.longTermEMA != nil {
s.Symbol, 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",
closePrice.Float64(), s.Symbol,
s.triggerEMA.Last(), closePrice.Float64(),
s.longTermEMA.Last(), s.triggerEMA.Last(),
kline.Volume, s.longTermEMA.Last(),
s.MinVolume.Float64(), kline.Volume,
kline) 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) quantity, err := s.calculateQuantity(session, types.SideTypeBuy, closePrice, kline.Volume)
if err != nil { if err != nil {