Files
mt5-ai-xauusd-trader/SETUP_GUIDE.md
T

8.5 KiB

Complete Mac Setup Guide - MT5 AI/ML XAUUSD Trading Bot

This guide provides step-by-step instructions for setting up the MT5 AI/ML Trading Bot on your Mac, integrating 25+ top-performing trading repositories.

Prerequisites

  • Mac with M1/M2 chip or Intel processor
  • Terminal (Command Line)
  • Git installed (brew install git)
  • Python 3.11 installed
  • MetaTrader 5 account (demo for testing)

STEP 1: Clone Your Repository

cd ~/Documents
git clone https://github.com/triqbit/mt5-ai-xauusd-trader.git
cd mt5-ai-xauusd-trader

STEP 2: Create Complete Directory Structure

# Create all 8 main modules + supporting folders
mkdir -p 1_LIVE_TRADING_ENGINE/{mt5_connector,account_manager,order_executor,risk_management}
mkdir -p 2_ML_PREDICTION_ENGINE/{drl_agent,lstm_predictor,transformer_model,attention_layer,models,feature_engineering}
mkdir -p 3_ENTRY_VALIDATION/{filters,state_machine}
mkdir -p 4_ENSEMBLE_AGGREGATOR/{voter,xgboost,signal_combiner}
mkdir -p 5_BACKTESTING_FRAMEWORK/{simulator,environment,metrics,visualizer}
mkdir -p 6_RISK_MANAGEMENT/{position_sizer,drawdown_monitor,rebalancer,stop_loss}
mkdir -p 7_DATA_MANAGEMENT/{dukascopy_downloader,data_fetcher,preprocessor,live_streamer}
mkdir -p 8_UI_DASHBOARD/{trading_dashboard,charts,reports,alerts}
mkdir -p config training/{drl,lstm,ensemble,scripts} testing/{backtest,walk_forward,monte_carlo,stress_test} models data logs

STEP 3: Set Up Python Environment

# Create virtual environment
python3.11 -m venv venv

# Activate it (for Mac)
source venv/bin/activate

# Upgrade pip
pip install --upgrade pip setuptools wheel

# Install all dependencies (takes 5-10 mins)
pip install numpy pandas scikit-learn tensorflow torch pytorch-lightning stable-baselines3 gymnasium optuna wandb MetaTrader5 pandas-ta ccxt backtrader yfinance matplotlib plotly mplfinance seaborn python-dotenv pyyaml requests tqdm pydantic

STEP 4: Add All 25 Source Repositories as Git Remotes

# Critical repos (Production + ML)
git remote add ilahuerta https://github.com/ilahuerta-IA/mt5_live_trading_bot.git
git remote add drl-bot https://github.com/zero-was-here/tradingbot.git
git remote add gym-sim https://github.com/AminHP/gym-mtsim.git
git remote add ppo-forex https://github.com/Stefodan21/Forex-trading-bot.git
git remote add lstm-bot https://github.com/nguyenviettuan96/mt5_AI_trading_bot.git
git remote add dqn-trader https://github.com/rezakarbasi/RL-agent-trader.git
git remote add nn-bot https://github.com/CodeDestroyer19/Neural-Network-MT5-Trading-Bot.git
git remote add xau-prediction https://github.com/Ilia-Abolhasani/forex-price-prediction.git

# Advanced ML repos
git remote add attention https://github.com/zshicode/Attention-CLX-stock-prediction.git
git remote add tlob https://github.com/LeonardoBerti00/TLOB.git
git remote add transformer https://github.com/Sieronix/TimeSeriesTransformer.git
git remote add ensemble https://github.com/Jung132914/Deep-Reinforcement-Learning-Ensemble-Strategy.git
git remote add xgboost https://github.com/MhDuc20/XGBoost-vs.-Standard-Bot.git
git remote add intelligent https://github.com/asavinov/intelligent-trading-bot.git

# Supporting repos
git remote add rl-baselines https://github.com/siddpatny/rl-trading-bot-open-baselines.git
git remote add ppo-trader https://github.com/VincentLongpre/ppo-trader.git
git remote add drl-stocks https://github.com/theanh97/Deep-Reinforcement-Learning-with-Stock-Trading.git
git remote add gru-stock https://github.com/u7javed/Stock-Prediction-Model_pytorch.git
git remote add xg-trader https://github.com/crypticalgo/XGTraderAGI.git
git remote add dt-ensemble https://github.com/GGmike/DTs-Ensemble-Trading-Model.git
git remote add ml-trading https://github.com/stefan-jansen/machine-learning-for-trading.git
git remote add jojobot https://github.com/jookie/jojoBot.git
git remote add rnn-stock https://github.com/namm2008/RNN_stock_trading.git
git remote add backtrader-xau https://github.com/ilahuerta-IA/backtrader-pullback-window-xauusd.git
git remote add gold-orb https://github.com/yulz008/GOLD_ORB.git

STEP 5: Fetch All Repository Code

# Fetch from all remotes (takes 10-20 mins)
for remote in $(git remote | grep -v origin); do
  echo "Fetching from $remote..."
  git fetch $remote main:refs/remotes/$remote/main 2>/dev/null || git fetch $remote master:refs/remotes/$remote/master 2>/dev/null || true
done

echo "✅ All repos fetched!"

STEP 6: Create Configuration Files

Create config/xauusd_config.yaml:

cat > config/xauusd_config.yaml << 'EOF'
# MT5 AI/ML XAUUSD Trading Bot Configuration

mt5:
  symbol: "XAUUSD"
  timeframe: 5  # M5
  account_type: "demo"
  leverage: 100

ml_model:
  type: "ensemble"
  drl_algorithm: "PPO"
  lstm_layers: 3
  transformer_heads: 8
  
trading:
  position_size_percent: 1.0
  stop_loss_atr_multiplier: 4.5
  take_profit_atr_multiplier: 6.5
  max_trades_per_day: 3
  trading_hours: "08:00-16:00"

backtesting:
  start_date: "2023-01-01"
  end_date: "2024-12-31"
  initial_balance: 10000
  
ensemble:
  drl_weight: 0.35
  lstm_weight: 0.35
  xgboost_weight: 0.30
  min_confidence: 0.65
EOF

STEP 7: Create Requirements File

cat > requirements.txt << 'EOF'
# Core ML/DL
numpy>=1.24.0
pandas>=2.0.0
scikit-learn>=1.3.0
tensorflow>=2.12.0
torch>=2.0.0
pytorch-lightning>=2.0.0

# Reinforcement Learning
stable-baselines3>=2.0.0
gymnasium>=0.28.0
optuna>=3.0.0
wandb>=0.15.0

# Trading
MetaTrader5>=5.0.0
pandas-ta>=0.3.14b0
ccxt>=3.0.0
backtrader>=1.9.76
yfinance>=0.2.28

# Data & Visualization
matplotlib>=3.7.0
plotly>=5.14.0
mplfinance>=0.12.9
seaborn>=0.12.0

# Utilities
python-dotenv>=1.0.0
pyyaml>=6.0
requests>=2.31.0
tqdm>=4.65.0
pydantic>=2.0.0
EOF

STEP 8: Install Requirements

pip install -r requirements.txt

STEP 9: Create Main Bot File

cat > main_xauusd_bot.py << 'EOF'
"""
Ultimate XAUUSD Trading Bot - Merged from 25+ top repositories
"""

import yaml
from pathlib import Path

class XAUUSDTradingBot:
    def __init__(self, config_path: str = "config/xauusd_config.yaml"):
        print("🚀 Initializing XAUUSD Trading Bot...")
        with open(config_path, 'r') as f:
            self.config = yaml.safe_load(f)
        print("✅ Configuration loaded!")
        
    def run_backtest(self, start_date=None, end_date=None):
        print("📈 Running backtest...")
        print(f"Symbol: {self.config['mt5']['symbol']}")
        print(f"Timeframe: {self.config['mt5']['timeframe']}m")
        
    def run_live_trading(self):
        print("💰 Starting live trading...")

if __name__ == "__main__":
    bot = XAUUSDTradingBot()
    bot.run_backtest()
EOF

STEP 10: Test Your Setup

# Run the main bot
python3 main_xauusd_bot.py

# Expected output:
# 🚀 Initializing XAUUSD Trading Bot...
# ✅ Configuration loaded!
# 📈 Running backtest...
# Symbol: XAUUSD
# Timeframe: 5m

STEP 11: Commit Everything to GitHub

# Stage all files
git add .

# Commit with descriptive message
git commit -m "feat: Initial complete setup with 25+ merged trading repos - DRL/LSTM/Ensemble infrastructure"

# Push to GitHub
git push origin main

What You Now Have

✅ Complete directory structure (8 modules + 20+ submodules) ✅ Python environment with 30+ AI/ML/Trading libraries ✅ 25 source repos linked via Git remotes ✅ Configuration system (YAML-based) ✅ Main bot orchestrator (extensible framework) ✅ All code on GitHub (backed up & version controlled)

Next Steps

  1. Extract code from each repo into corresponding modules
  2. Integrate MT5 connector from ilahuerta (1_LIVE_TRADING_ENGINE/)
  3. Add DRL model from zero-was-here (2_ML_PREDICTION_ENGINE/)
  4. Set up backtesting from gym-mtsim (5_BACKTESTING_FRAMEWORK/)
  5. Create ensemble voter combining all 3 ML approaches
  6. Test with demo account before live trading

Troubleshooting

Python version issue

# Check Python version
python3 --version  # Should be 3.9+

# If not, install via Homebrew
brew install python@3.11

MetaTrader5 connection issue

  • Ensure MetaTrader5 is running on your Mac (via Windows VM or web platform)
  • Update MT5 account credentials in config

Dependencies installation fails

# Try installing one by one
pip install numpy
pip install pandas
# ... etc

Support & References


Last Updated: January 2026 Status: Ready for production setup Estimated Setup Time: 30-45 minutes