@@ -184,25 +184,37 @@ def signal(self, df: pd.DataFrame) -> int:
184184
185185 # Only trade on STRONG trend changes with multiple confirmations
186186 if direction != prev_direction :
187- # Wait for strong confirmation - price must be significantly above/below SuperTrend
187+ # Wait for strong confirmation: price clearly above/below the SuperTrend line
188188 atr = float (row .get ('ATR' , 0 ))
189189 if atr > 0 :
190190 price_distance = abs (current_price - supertrend ) / atr
191191
192- # Balanced thresholds for good entries
193- if direction > 0 and current_price > supertrend and price_distance > 0.3 :
194- # Additional confirmation: price should be rising
192+ # More aggressive thresholds to generate signals on trend change
193+ if direction > 0 and current_price > supertrend and price_distance > 0.1 :
194+ # Additional confirmation: positive momentum
195195 price_change = current_price - float (prev ['Close' ])
196196 if price_change > 0 :
197197 return 1 # Buy signal
198- elif direction < 0 and current_price < supertrend and price_distance > 0.3 :
199- # Additional confirmation: price should be falling
198+ elif direction < 0 and current_price < supertrend and price_distance > 0.1 :
199+ # Additional confirmation: negative momentum
200200 price_change = current_price - float (prev ['Close' ])
201201 if price_change < 0 :
202202 return - 1 # Sell signal
203-
204- # No additional signals - only trade on very clear trend changes
205-
203+
204+ # NEW: Allow signals on confirmed price cross even without Direction change
205+ # Rules: price crosses SuperTrend line + sufficient distance/ATR + momentum confirmation
206+ atr = float (row .get ('ATR' , 0 ))
207+ if atr > 0 :
208+ price_distance = abs (current_price - supertrend ) / atr
209+ price_change = current_price - float (prev ['Close' ])
210+
211+ # Confirmed bullish cross
212+ if current_price > supertrend and direction > 0 and price_distance > 0.1 and price_change > 0 :
213+ return 1
214+ # Confirmed bearish cross
215+ if current_price < supertrend and direction < 0 and price_distance > 0.1 and price_change < 0 :
216+ return - 1
217+
206218 return 0 # Hold
207219
208220 def volatility (self , df : pd .DataFrame ) -> Optional [float ]:
0 commit comments