From f159c464380ba12d283cd1bddddc661a3cff3b32 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 11 Jan 2021 07:55:01 +0100 Subject: [PATCH] Include stoploss_on_exchange in stoploss_guard fix #4183 --- docs/includes/protections.md | 2 +- freqtrade/plugins/protections/stoploss_guard.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/includes/protections.md b/docs/includes/protections.md index 8465392a4..95fa53ad2 100644 --- a/docs/includes/protections.md +++ b/docs/includes/protections.md @@ -58,7 +58,7 @@ The below example stops trading for all pairs for 4 candles after the last trade ``` !!! Note - `StoplossGuard` considers all trades with the results `"stop_loss"` and `"trailing_stop_loss"` if the resulting profit was negative. + `StoplossGuard` considers all trades with the results `"stop_loss"`, `"stoploss_on_exchange"` and `"trailing_stop_loss"` if the resulting profit was negative. `trade_limit` and `lookback_period` will need to be tuned for your strategy. #### MaxDrawdown diff --git a/freqtrade/plugins/protections/stoploss_guard.py b/freqtrade/plugins/protections/stoploss_guard.py index 193907ddc..92fae54cb 100644 --- a/freqtrade/plugins/protections/stoploss_guard.py +++ b/freqtrade/plugins/protections/stoploss_guard.py @@ -53,8 +53,9 @@ class StoplossGuard(IProtection): # trades = Trade.get_trades(filters).all() trades1 = Trade.get_trades_proxy(pair=pair, is_open=False, close_date=look_back_until) - trades = [trade for trade in trades1 if str(trade.sell_reason) == SellType.STOP_LOSS.value - or (str(trade.sell_reason) == SellType.TRAILING_STOP_LOSS.value + trades = [trade for trade in trades1 if (str(trade.sell_reason) in ( + SellType.TRAILING_STOP_LOSS.value, SellType.STOP_LOSS.value, + SellType.STOPLOSS_ON_EXCHANGE.value) and trade.close_profit < 0)] if len(trades) > self._trade_limit: