Fix on Sell order lossing by blocking time
This commit is contained in:
@@ -804,6 +804,28 @@ class SignalAggregator:
|
||||
)
|
||||
report.signal_quality = "D"
|
||||
report.trade_setup = None
|
||||
elif xau_is_sell_dir and self.config.xau_strategy.sell_blocked_hours_utc:
|
||||
# ── 6g3. XAU SELL hour gate (opt-in via per-TF factories) ──
|
||||
# Evaluated on the bar's CLOSE time (= entry time under
|
||||
# next-open fills), the same clock the session filter and
|
||||
# backtest replay use — NOT the bar label hour.
|
||||
try:
|
||||
close_h = (
|
||||
pd.Timestamp(report.timestamp)
|
||||
+ pd.Timedelta(
|
||||
seconds=ForexDataProvider.CANDLE_SECONDS[
|
||||
self.config.primary_timeframe
|
||||
]
|
||||
)
|
||||
).hour
|
||||
except Exception:
|
||||
close_h = None
|
||||
if close_h in self.config.xau_strategy.sell_blocked_hours_utc:
|
||||
report.warnings.append(
|
||||
f"SELL FILTER: {close_h:02}:00 UTC entry blocked for shorts"
|
||||
)
|
||||
report.signal_quality = "D"
|
||||
report.trade_setup = None
|
||||
|
||||
# ── 6h. EUR/USD regime + quality + risk gate ──────────────
|
||||
if report.display_name == "EUR/USD" and self.config.eur_strategy.enabled:
|
||||
|
||||
Reference in New Issue
Block a user