mirror of
https://github.com/FXDavid-OffbeatForex/MBT.git
synced 2026-11-02 12:06:12 +00:00
- Timezone-alignment fix: fetch_aligned matches signals to bars by price (MQL5 server time vs Python UTC ~3h offset invalidated prior backtests) - Symbol-aware transaction costs (real spread from MT5) baked into backtest - One-trade-per-setup (sequential) mode; % monthly/yearly returns in report - Exit optimizer (SL x RR sweep, train/test split) - Gold analysis scripts: per-year, ADX filter, efficiency ratio, HTF alignment - Frozen signal snapshots (gold_signals.csv, arm_signals_EURUSD_H1.csv) Findings: EURUSD = coin flip after costs. GOLD = modest real trend edge; ADX>35 filter validated train+test (halves worst-year drawdown). Efficiency Ratio and daily-trend HTF filters tested and rejected (not robust both halves). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from core.optimize_exits import optimize_exits
|
|
import time
|
|
|
|
t0 = time.time()
|
|
r = optimize_exits()
|
|
print(f"took {round(time.time()-t0,1)}s")
|
|
print("train:", r["train_period"].replace("→", "to"))
|
|
print("test :", r["test_period"].replace("→", "to"))
|
|
print("cost/trade (price):", r["cost_price_per_trade"])
|
|
print()
|
|
|
|
rrs = sorted(set(g["RR"] for g in r["grid"]))
|
|
ms = sorted(set(g["M"] for g in r["grid"]))
|
|
|
|
print("=== TRAIN: expectancy (R per trade) — rows=SL mult, cols=RR ===")
|
|
header = "SL\\RR".ljust(7) + "".join(f"{rr:>8}" for rr in rrs)
|
|
print(header)
|
|
for M in ms:
|
|
row = f"{M:>6} "
|
|
for rr in rrs:
|
|
g = next(x for x in r["grid"] if x["M"] == M and x["RR"] == rr)
|
|
row += f"{g['expectancy']:>8.3f}"
|
|
print(row)
|
|
|
|
print()
|
|
print("=== TRAIN: net R — rows=SL mult, cols=RR ===")
|
|
print(header)
|
|
for M in ms:
|
|
row = f"{M:>6} "
|
|
for rr in rrs:
|
|
g = next(x for x in r["grid"] if x["M"] == M and x["RR"] == rr)
|
|
row += f"{g['net_r']:>8.0f}"
|
|
print(row)
|
|
|
|
def show(label, d):
|
|
print(f"\n{label}: M={d['M']} RR={d['RR']} | trades={d['trades']} "
|
|
f"WR={d['win_rate']}% PF={d['profit_factor']} "
|
|
f"exp={d['expectancy']}R net={d['net_r']}R maxDD={d['max_dd_r']}R")
|
|
|
|
show("TRAIN BEST", r["train_best"])
|
|
show(" -> on LOCKED TEST", r["test_result"])
|
|
show("BASELINE 2.5/3.5 on TEST", r["baseline_on_test"])
|