# GENESIS โ€” Autonomous MT5 Trading System > **Powered by [API2TRADE](https://app.api2trade.com)** โ€” the REST API for MetaTrader 5 [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Python 3.11](https://img.shields.io/badge/Python-3.11-brightgreen)](https://python.org) [![MT5 via API2TRADE](https://img.shields.io/badge/MT5-API2TRADE-orange)](https://app.api2trade.com) GENESIS is a fully autonomous, multi-strategy Forex trading system that connects to any **MetaTrader 5** account via the [API2TRADE](https://app.api2trade.com) REST API. It runs six independent strategy bots in parallel, managed by **Hermes** โ€” an LLM-powered orchestration brain. --- ## ๐Ÿ— Architecture ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ HERMES (Brain) โ”‚ โ”‚ GPT-4o-mini ยท Hourly LLM โ”‚ โ”‚ Macro analysis + routing โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ GENESIS Autonomous Engine โ”‚ โ”‚ (genesis_autonomous.py ยท every 5min) โ”‚ โ””โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ ARES APOLLO ATHENA ARTEMIS ZEUS HEPHAESTUS M1 M5 M5 H1 M5 Grid BB+RSI EMA BB+RSI Ichimoku ICT Martingale โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ API2TRADE REST โ”‚ โ”‚ app.api2trade.comโ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ MetaTrader 5 โ”‚ โ”‚ (any broker) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- ## ๐Ÿค– Strategy Bots | Bot | Timeframe | Strategy | Symbols | Expected Signals | |-----|-----------|----------|---------|-----------------| | **ARES** | M1 | Bollinger Bands + RSI mean reversion | EURUSD, GBPUSD | 10โ€“30/day | | **APOLLO** | M5 | EMA 9/21 crossover trend following | EURUSD, GBPUSD | 5โ€“15/day | | **ATHENA** | M5 | Multi-TF BB + RSI ranging | EURUSD | 5โ€“15/day | | **ARTEMIS** | H1 | Ichimoku Kumo breakout | EURUSD, GBPUSD, GBPJPY | 2โ€“8/day | | **ZEUS** | M5 | ICT Smart Money โ€” Liquidity + FVG + OB | EURUSD, GBPUSD, XAUUSD | 3โ€“10/day | | **HEPHAESTUS** | โ€” | Grid / Martingale cycling | Any | Continuous | --- ## ๐Ÿ“‹ Prerequisites ### 1. API2TRADE Account (Required) GENESIS communicates with MT5 exclusively through the [API2TRADE](https://app.api2trade.com) REST API โ€” no local MT5 installation, no Windows VPS required. 1. Sign up at **[app.api2trade.com](https://app.api2trade.com)** 2. Connect your MetaTrader 5 account 3. Copy your **Account UUID** and **API Key** from the dashboard > **Cost:** โ‚ฌ12/month per connected MT5 account ยท No per-call fees ยท Unlimited requests ### 2. Telegram Bot (Required for alerts) 1. Message [@BotFather](https://t.me/BotFather) โ†’ `/newbot` 2. Copy the bot token 3. Get your Chat ID from [@userinfobot](https://t.me/userinfobot) ### 3. OpenAI API Key (Optional โ€” for Hermes brain) 1. Get a key at [platform.openai.com/api-keys](https://platform.openai.com/api-keys) 2. Cost: ~$0.10โ€“0.50/day using `gpt-4o-mini` 3. Without it: GENESIS runs strategies autonomously without LLM macro analysis --- ## ๐Ÿš€ Quick Start ### Option A โ€” Docker (Recommended for local testing) ```bash # 1. Clone the repo git clone https://github.com/api2trade/Genesis-Metatrader-Automatic-AI-Trading-System.git cd Genesis-Metatrader-Automatic-AI-Trading-System # 2. Run the setup wizard (generates your .env) bash setup.sh # 3. Start the container docker compose up -d # 4. Watch it run docker logs -f genesis ``` ### Option B โ€” VPS Production (Ubuntu 22.04) ```bash # 1. Clone the repo on your VPS git clone https://github.com/api2trade/Genesis-Metatrader-Automatic-AI-Trading-System.git cd Genesis-Metatrader-Automatic-AI-Trading-System # 2. Run setup wizard bash setup.sh # 3. Install cron jobs, CLI shortcuts and log folders bash install.sh # 4. Verify cron schedule is active crontab -l # 5. Watch live logs tail -f /var/log/hermes/autonomous.log ``` --- ## ๐Ÿ”ง Manual Setup If you prefer to configure manually instead of using `setup.sh`: ```bash cp .env.example .env nano .env # Fill in your credentials ``` Required fields: | Variable | Where to get it | |----------|----------------| | `MT5_ACCOUNT_UUID` | [app.api2trade.com](https://app.api2trade.com) โ†’ Dashboard | | `MT5_API_KEY` | [app.api2trade.com](https://app.api2trade.com) โ†’ API Keys | | `MT5_API_USER` | Your API2TRADE username | | `MT5_API_PASS` | Your API2TRADE password | | `TELEGRAM_BOT_TOKEN` | [@BotFather](https://t.me/BotFather) | | `TELEGRAM_CHAT_ID` | [@userinfobot](https://t.me/userinfobot) | --- ## ๐Ÿ’ป Usage ### Strategy Analysis ```bash # Single strategy analysis (no trade placed) docker exec -it genesis ares analyze EURUSDxx docker exec -it genesis apollo analyze GBPUSDxx docker exec -it genesis athena analyze EURUSDxx docker exec -it genesis artemis analyze GBPUSDxx docker exec -it genesis zeus analyze XAUUSDxx # Scan ALL strategies on one symbol at once docker exec -it genesis genesis-scan EURUSDxx docker exec -it genesis genesis-scan GBPUSDxx ``` ### Live Logs ```bash # All decisions docker exec -it genesis tail -f /var/log/hermes/autonomous.log # Trade journal (JSONL) docker exec -it genesis tail -f /var/log/hermes/trade_journal.jsonl # LLM macro cycles docker exec -it genesis tail -f /var/log/hermes/trading_cycle.log ``` ### Strategy Output Format Every strategy returns a JSON object: ```json { "action": "trade", "strategy": "ares-bb-rsi-m1", "symbol": "EURUSDxx", "direction": "Buy", "entry": 1.08542, "stop_loss": 1.08392, "take_profit": 1.08842, "volume": 0.1, "rr_ratio": 2.0, "sl_pips": 15.0, "confidence": "high", "reason": "RSI oversold + BB lower touch + session active" } ``` --- ## ๐Ÿ“ Project Structure ``` Genesis-Metatrader-Automatic-AI-Trading-System/ โ”œโ”€โ”€ setup.sh # โ† Interactive setup wizard (start here) โ”œโ”€โ”€ install.sh # โ† VPS production installer โ”œโ”€โ”€ docker-compose.yml # โ† Docker deployment โ”œโ”€โ”€ Dockerfile โ”œโ”€โ”€ .env.example # โ† Credential template โ”‚ โ”œโ”€โ”€ core/ โ”‚ โ”œโ”€โ”€ genesis_autonomous.py # Main engine โ€” runs every 5min via cron โ”‚ โ”œโ”€โ”€ trading_cycle.py # Hermes LLM macro cycle โ€” hourly โ”‚ โ”œโ”€โ”€ genesis_daily_report.py # Daily P&L Telegram report โ”‚ โ”œโ”€โ”€ genesis_brain_feed.py # Hourly Telegram market summary โ”‚ โ”œโ”€โ”€ heartbeat.py # System health check โ”‚ โ””โ”€โ”€ tg_notify.py # Telegram helper โ”‚ โ”œโ”€โ”€ strategies/ โ”‚ โ”œโ”€โ”€ ares/ # BB+RSI M1 mean reversion โ”‚ โ”‚ โ”œโ”€โ”€ ares_cycle.py # Strategy logic + API2TRADE bridge โ”‚ โ”‚ โ””โ”€โ”€ ares_tool.py # CLI: ares analyze/execute EURUSDxx โ”‚ โ”œโ”€โ”€ apollo/ # EMA trend following โ”‚ โ”œโ”€โ”€ athena/ # BB+RSI multi-TF ranging โ”‚ โ”œโ”€โ”€ artemis/ # Ichimoku H1 breakout โ”‚ โ”œโ”€โ”€ zeus/ # ICT Smart Money M5 โ”‚ โ””โ”€โ”€ hephaestus/ # Grid/Martingale โ”‚ โ”œโ”€โ”€ configs/ โ”‚ โ”œโ”€โ”€ ares_config.yaml # ARES parameters (BB period, RSI thresholds, etc.) โ”‚ โ”œโ”€โ”€ apollo_config.yaml โ”‚ โ”œโ”€โ”€ athena_config.yaml โ”‚ โ”œโ”€โ”€ artemis_config.yaml โ”‚ โ”œโ”€โ”€ zeus_config.yaml โ”‚ โ””โ”€โ”€ hephaestus_config.yaml โ”‚ โ””โ”€โ”€ backtest/ โ”œโ”€โ”€ backtest.py # Python backtester using yfinance โ””โ”€โ”€ BB_RSI_MeanReversion.mq5 # MT5 Expert Advisor (manual backtest) ``` --- ## โšก API2TRADE โ€” How It Works GENESIS uses API2TRADE as the bridge between Python and MetaTrader 5. Every strategy calls these endpoints directly: ```python # Get account balance GET /AccountSummary?id={session_uuid} โ†’ {"balance": 10000.0, "equity": 10000.0, "currency": "USD"} # Get live quote GET /Quote?id={session_uuid}&symbol=EURUSDxx โ†’ {"Bid": 1.08540, "Ask": 1.08542} # Place a trade GET /OrderSendSafe?id={session_uuid}&symbol=EURUSDxx&operation=Buy&volume=0.1&stoploss=1.083&takeprofit=1.090&comment=GENESIS-ARES โ†’ {"ticket": 12345678} # Close a position GET /OrderCloseSafe?id={session_uuid}&ticket=12345678&lots=0.1 ``` No WebSocket setup, no local MT5 terminal, no Windows server. Just REST calls from any Python environment. > ๐Ÿ’ก **Sign up at [app.api2trade.com](https://app.api2trade.com) to get your session UUID and API key.** --- ## ๐Ÿ›ก Risk Management Hard limits enforced before **every** trade โ€” cannot be bypassed: | Limit | Default | Config | |-------|---------|--------| | Max risk per trade | **2% of balance** | `MAX_RISK_PCT` in `.env` | | Max lot size | **3.0 lots** | `MAX_LOTS` in `.env` | | Max open positions | **4** | `MAX_POSITIONS` in `.env` | | Stop loss | **Required** (5โ€“150 pips) | Per strategy config | | Spread filter | **1.0โ€“3.0 pips** | Per strategy YAML | | News filter | **ยฑ15 min** around high-impact | Per strategy YAML | --- ## โš™๏ธ Configuration Each strategy has a dedicated YAML config in `configs/`. Example for ARES: ```yaml # configs/ares_config.yaml strategy: name: ARES magic_number: 1001 bollinger: period: 20 std_dev: 2.0 rsi: period: 14 oversold: 30 overbought: 70 risk: risk_pct: 0.01 # 1% per trade max_spread_pips: 1.0 min_rr_ratio: 1.5 sessions: allowed: - {start: 7, end: 20} # GMT hours ``` --- ## ๐Ÿ–ฅ VPS Deployment (Recommended) For 24/7 autonomous trading, deploy on a Ubuntu 22.04 VPS: ```bash # Minimum spec: 2 vCPU, 2GB RAM, 20GB SSD # Cost: ~โ‚ฌ4โ€“8/month (Hetzner, Contabo, DigitalOcean) bash setup.sh # Configure credentials bash install.sh # Install Python, venv, cron jobs, CLI shortcuts ``` The installer sets up: - Python 3.11 virtual environment at `/opt/hermes-agent/.venv-hermes` - Cron job: `genesis_autonomous.py` every 5 minutes - Cron job: `trading_cycle.py` (Hermes LLM) every hour - Log rotation at `/var/log/hermes/` - CLI shortcuts: `ares`, `apollo`, `athena`, `artemis`, `zeus`, `hephaestus`, `genesis-scan` --- ## ๐Ÿ“Š Backtesting ```bash # Backtest ARES on EURUSD (last 12 months) python3 backtest/backtest.py --strategy ares --symbol EURUSD --days 365 # Or open the MT5 EA in MetaEditor for native backtesting # backtest/BB_RSI_MeanReversion.mq5 ``` --- ## ๐Ÿค Contributing GENESIS is open source under **GPL v3** โ€” forks must also be open source. 1. Fork the repo 2. Create your feature branch (`git checkout -b feature/my-strategy`) 3. Commit your changes 4. Open a Pull Request --- ## โš ๏ธ Disclaimer This software is for **educational and research purposes**. Forex trading involves substantial risk of loss. Past performance does not guarantee future results. Always test on a **demo account** before trading with real money. The authors accept no responsibility for financial losses. --- ## ๐Ÿ“„ License GPL-3.0 ยท See [LICENSE](LICENSE) ---
**Built with API2TRADE ยท [app.api2trade.com](https://app.api2trade.com)** *Connect any MT5 account to Python in minutes ยท โ‚ฌ12/month per account*