# GENESIS โ Autonomous MT5 Trading System > **Powered by [API2TRADE](https://app.api2trade.com)** โ the REST API for MetaTrader 5 [](https://www.gnu.org/licenses/gpl-3.0) [](https://python.org) [](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) ---