Overview
The XAUUSD Trading Bot requires MetaTrader 5 (MT5) to access real-time market data and execute trades. This guide walks you through the complete installation and configuration process.Installation Steps
Download MetaTrader 5
Visit the official MetaTrader 5 website or your broker’s platform to download MT5 for your operating system:
- Windows: Download the installer from MetaTrader 5
- macOS: Use Wine or a Windows VM
- Linux: Use Wine compatibility layer
Install MetaTrader 5
Run the installer and follow the on-screen instructions:
- Accept the license agreement
- Choose installation directory
- Wait for installation to complete
- Launch MetaTrader 5
Create or Login to Trading Account
When MT5 launches for the first time:
- New users: Create a demo account to test the bot
- Existing users: Login with your broker credentials
For testing purposes, a demo account is recommended. The bot has been tested with 65% accuracy on real accounts.
Enable Algo Trading
To allow the Python API to connect:
- Open MT5 and go to Tools → Options
- Navigate to the Expert Advisors tab
- Check the following options:
- ✅ Allow algorithmic trading
- ✅ Allow DLL imports
- ✅ Allow WebRequest for listed URL
- Click OK to save
Install Python MT5 Package
Install the MetaTrader5 Python package:This package is required for the bot to communicate with MT5.
Common Issues
Connection Failed Error
Connection Failed Error
If you see a connection failed error:
- Ensure MT5 is running and logged in
- Check that algorithmic trading is enabled
- Restart both MT5 and your Python script
- Verify you’re using a 64-bit Python installation (matches MT5)
Symbol 'XAUUSD' Not Found
Symbol 'XAUUSD' Not Found
If the bot can’t find the XAUUSD symbol:
- Open MT5’s Market Watch (Ctrl+M)
- Right-click and select Show All
- Find and enable XAUUSD (Gold vs US Dollar)
- Some brokers use different naming: GOLD, XAU/USD, or XAUUSD.m
You may need to modify the symbol name in the bot’s code to match your broker’s naming convention.
Linux/macOS Installation
Linux/macOS Installation
For non-Windows systems:
- Install Wine:
sudo apt install wine(Ubuntu/Debian) - Download Windows MT5 installer
- Run via Wine:
wine mt5setup.exe - Use Wine prefix when running the bot
Trading Account Configuration
Recommended Settings for XAUUSD
The bot analyzes XAUUSD across 6 timeframes: Daily (D1), 4-Hour (H4), 1-Hour (H1), 30-Minute (M30), 15-Minute (M15), and 5-Minute (M5).
- Leverage: 1:100 or higher (for gold trading)
- Minimum Balance: $1000+ recommended (bot uses 1% risk per trade)
- Spread: Choose a broker with competitive XAUUSD spreads
- Execution: Market execution preferred