From 84a194bcabc7633cf8b9795bee7d6be5e5d98b6c Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 22 Oct 2022 11:45:21 +0200 Subject: [PATCH] Simplify stoploss logic by removing redundant condition --- freqtrade/strategy/interface.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 96e3065c4..05744e845 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -1085,9 +1085,7 @@ class IStrategy(ABC, HyperStrategyMixin): else: logger.warning("CustomStoploss function did not return valid stoploss") - sl_lower_long = (trade.stop_loss < (low or current_rate) and not trade.is_short) - sl_higher_short = (trade.stop_loss > (high or current_rate) and trade.is_short) - if self.trailing_stop and (sl_lower_long or sl_higher_short): + if self.trailing_stop and dir_correct: # trailing stoploss handling sl_offset = self.trailing_stop_positive_offset @@ -1101,7 +1099,7 @@ class IStrategy(ABC, HyperStrategyMixin): if self.trailing_stop_positive is not None and bound_profit > sl_offset: stop_loss_value = self.trailing_stop_positive logger.debug(f"{trade.pair} - Using positive stoploss: {stop_loss_value} " - f"offset: {sl_offset:.4g} profit: {current_profit:.2%}") + f"offset: {sl_offset:.4g} profit: {bound_profit:.2%}") trade.adjust_stop_loss(bound or current_rate, stop_loss_value)