Revert wrong condition
This commit is contained in:
parent
e19d95b63e
commit
bc10b451fe
@ -840,9 +840,9 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
else:
|
else:
|
||||||
logger.warning("CustomStoploss function did not return valid stoploss")
|
logger.warning("CustomStoploss function did not return valid stoploss")
|
||||||
|
|
||||||
sl_lower_short = (trade.stop_loss < (low or current_rate) and not trade.is_short)
|
sl_lower_long = (trade.stop_loss < (low or current_rate) and not trade.is_short)
|
||||||
sl_higher_long = (trade.stop_loss > (high or current_rate) and trade.is_short)
|
sl_higher_short = (trade.stop_loss > (high or current_rate) and trade.is_short)
|
||||||
if self.trailing_stop and (sl_lower_short or sl_higher_long):
|
if self.trailing_stop and (sl_lower_long or sl_higher_short):
|
||||||
# trailing stoploss handling
|
# trailing stoploss handling
|
||||||
sl_offset = self.trailing_stop_positive_offset
|
sl_offset = self.trailing_stop_positive_offset
|
||||||
|
|
||||||
@ -851,15 +851,9 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
bound_profit = current_profit if not bound else trade.calc_profit_ratio(bound)
|
bound_profit = current_profit if not bound else trade.calc_profit_ratio(bound)
|
||||||
|
|
||||||
# Don't update stoploss if trailing_only_offset_is_reached is true.
|
# Don't update stoploss if trailing_only_offset_is_reached is true.
|
||||||
if not (self.trailing_only_offset_is_reached and (
|
if not (self.trailing_only_offset_is_reached and bound_profit < sl_offset):
|
||||||
(bound_profit < sl_offset and not trade.is_short) or
|
|
||||||
(bound_profit > sl_offset and trade.is_short)
|
|
||||||
)):
|
|
||||||
# Specific handling for trailing_stop_positive
|
# Specific handling for trailing_stop_positive
|
||||||
if self.trailing_stop_positive is not None and (
|
if self.trailing_stop_positive is not None and bound_profit > sl_offset:
|
||||||
(bound_profit > sl_offset and not trade.is_short) or
|
|
||||||
(bound_profit < sl_offset and trade.is_short)
|
|
||||||
):
|
|
||||||
stop_loss_value = self.trailing_stop_positive
|
stop_loss_value = self.trailing_stop_positive
|
||||||
logger.debug(f"{trade.pair} - Using positive stoploss: {stop_loss_value} "
|
logger.debug(f"{trade.pair} - Using positive stoploss: {stop_loss_value} "
|
||||||
f"offset: {sl_offset:.4g} profit: {current_profit:.4f}%")
|
f"offset: {sl_offset:.4g} profit: {current_profit:.4f}%")
|
||||||
|
Loading…
Reference in New Issue
Block a user