Skip to content

feat: add MetaTrader 5 bridge for real-time Kronos inference#292

Open
janpauldelacruz wants to merge 8 commits into
shiyu-coder:masterfrom
janpauldelacruz:feature/mt5-bridge
Open

feat: add MetaTrader 5 bridge for real-time Kronos inference#292
janpauldelacruz wants to merge 8 commits into
shiyu-coder:masterfrom
janpauldelacruz:feature/mt5-bridge

Conversation

@janpauldelacruz
Copy link
Copy Markdown

Summary

This PR adds the first production-grade MetaTrader 5 ↔ Kronos bridge, enabling live traders to use Kronos OHLCV forecasts directly inside MT5 Expert Advisors — the world's most widely used retail trading platform (millions of users).

What's included

  • examples/mt5_bridge/pooyer_bridge.py — Flask server that loads Kronos and serves predictions via HTTP on port 7799
  • examples/mt5_bridge/POOYER.mq5 — MT5 Expert Advisor that sends OHLCV bars via WebRequest and executes signals
  • examples/mt5_bridge/README.md — Full documentation, API reference, and quick start guide
  • examples/mt5_bridge/requirements_bridge.txt — Python dependencies

Why this matters

Kronos has no existing integration with live trading platforms. This bridge closes that gap — any MT5 user worldwide can now point their EA at a local Kronos instance and trade with foundation model forecasts.

Features

  • Multi-symbol support (XAUUSD, EURUSD, GBPUSD, BTCUSD, indices)
  • Works with Kronos-mini on CPU only — no GPU required
  • Built-in bar-hash cache (same candle = instant response)
  • ATR-based signal engine: direction + confidence + SL/TP
  • Full risk management: % sizing, spread guard, daily loss limit, kill hours, asymmetric breakeven
  • Health watchdog endpoint for EA monitoring

Tested on

XAUUSD, EURUSD, GBPUSD with Kronos-mini (CPU, ~800-2000ms inference)

janpauldelacruz and others added 8 commits May 8, 2026 02:16
…ment length

- pooyer_bridge.py: double-checked locking for _load_model() via _model_lock
- pooyer_bridge.py: inner double-check in multi_predict before inference
- pooyer_bridge.py: clear_cache() now protected by _lock
- pooyer_bridge.py: freq param in payload propagated to _run_inference timestamps
- requirements_bridge.txt: add torch>=2.0.0 (required for Kronos model)
- POOYER.mq5: ManageOpenPositions — guard cur_sl==0 before breakeven compare
- POOYER.mq5: FLAT signals handled explicitly (no longer logged as fetch failure)
- POOYER.mq5: order comment truncated to 31 chars (MT5 limit)
- POOYER.mq5: PingHealth timeout 3000ms → 1500ms to unblock bar processing
- README.md: remove reference to pooyer_dashboard.html (file not in commit)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Percentile path SL/TP, flip-resistant dynamic exit, ensemble variance
confidence, NO_TRADE state, forecast expiry, 2.5×ATR SL hard cap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Full task-by-task build plan: bridge (ensemble variance, percentile
path SL/TP, /recheck), EA (flip-resistant exit, forecast expiry),
README, launcher scripts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant