diff --git a/core/models/position_risk.py b/core/models/position_risk.py index f14d520b..9d846e4a 100644 --- a/core/models/position_risk.py +++ b/core/models/position_risk.py @@ -415,7 +415,7 @@ def sl_ats(self, side: PositionSide, ta: TechAnalysis, sl: float) -> "float": ) if side == PositionSide.LONG: - l_constr = low_smooth[-1] + l_constr = min(low_smooth[-1], low_smooth[-2]) adjusted_sl = ( min(l_constr, np.max(ats)) if bullish else min(l_constr, ats[-1]) ) @@ -423,7 +423,7 @@ def sl_ats(self, side: PositionSide, ta: TechAnalysis, sl: float) -> "float": return max(sl, adjusted_sl) if side == PositionSide.SHORT: - h_constr = high_smooth[-1] + h_constr = max(high_smooth[-1], high_smooth[-2]) adjusted_sl = ( max(h_constr, np.min(ats)) if bearish else max(h_constr, ats[-1]) )