mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
pivotshort: also check isClosed
This commit is contained in:
parent
f883d42c58
commit
016ddfd8cd
|
@ -312,7 +312,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
session.MarketDataStream.OnKLine(func(kline types.KLine) {
|
session.MarketDataStream.OnKLine(func(kline types.KLine) {
|
||||||
// TODO: handle stop loss here, faster than closed kline
|
// TODO: handle stop loss here, faster than closed kline
|
||||||
_, found := s.findHigherPivotLow(kline.Close)
|
_, found := s.findHigherPivotLow(kline.Close)
|
||||||
if !found && s.Entry.Immediate && s.Position.IsDust(kline.Close) {
|
if !found && s.Entry.Immediate && (s.Position.IsClosed() || s.Position.IsDust(kline.Close)) {
|
||||||
s.Notify("price breaks the previous low, submitting market sell to open a short position")
|
s.Notify("price breaks the previous low, submitting market sell to open a short position")
|
||||||
s.placeMarketSell(ctx, orderExecutor)
|
s.placeMarketSell(ctx, orderExecutor)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user