Skip to content

Commit de73072

Browse files
committed
Update strategy signals and timers; fix comments language; minor tuning
1 parent e23f259 commit de73072

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

forexsmartbot/strategies/ml_adaptive_supertrend.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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]:

forexsmartbot/ui/enhanced_main_window.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ def start_signal_generation(self, strategy, symbols):
10491049
# Start real-time signal generation timer (less frequent to prevent freezing)
10501050
self.signal_timer = QTimer()
10511051
self.signal_timer.timeout.connect(lambda: self.generate_signals(strategy, symbols))
1052-
self.signal_timer.start(600000) # Check every 10 minutes (reduced frequency)
1052+
self.signal_timer.start(300000) # Check every 5 minutes (more frequent)
10531053

10541054
# Start monitoring timer (less frequent)
10551055
self.monitor_timer = QTimer()
@@ -1081,7 +1081,7 @@ def generate_signals(self, strategy, symbols):
10811081
current_time = datetime.now()
10821082
if symbol in self.signal_cooldown:
10831083
time_since_last = (current_time - self.signal_cooldown[symbol]).total_seconds()
1084-
if time_since_last < 900: # 15 minute cooldown
1084+
if time_since_last < 600: # 10 minute cooldown
10851085
continue
10861086

10871087
# Get current price (simplified to prevent blocking)

0 commit comments

Comments
 (0)