2026-01-08.19-32-52.mp4
- MetaTrader 5 (running with Exness account)
- Python 3.10+ with pip
- Node.js 18+ with npm
- PostgreSQL 15+
- Git
- Docker (optional, for easier PostgreSQL setup)
- All except MT5 are pre-installed
- MT5 must run on your local machine
mql5-algo-builder/
βββ backend/
β βββ app/
β β βββ __init__.py
β β βββ main.py # FastAPI entry point
β β βββ config.py # Configuration
β β βββ database.py # Database models
β β βββ api/
β β β βββ __init__.py
β β β βββ routes.py # API endpoints
β β βββ services/
β β βββ __init__.py
β β βββ mt5_service.py # MT5 integration
β β βββ mql5_generator.py # Code generator
β β βββ backtest_engine.py # Backtesting
β βββ migrations/
β β βββ init_db.sql # Database schema
β βββ requirements.txt # Python dependencies
β βββ .env.example
βββ frontend/
β βββ public/
β β βββ index.html
β βββ src/
β β βββ components/
β β β βββ Chart.jsx # Chart component
β β β βββ DrawingTools.jsx # Drawing interface
β β β βββ StrategyBuilder.jsx # Strategy config
β β β βββ BacktestPanel.jsx # Results display
β β β βββ CodePreview.jsx # MQL5 code viewer
β β βββ services/
β β β βββ api.js # API client
β β β βββ websocket.js # WebSocket client
β β βββ styles/
β β β βββ terminal.css # Terminal styling
β β βββ App.jsx # Main component
β β βββ index.js # React entry
β β βββ index.css # Global styles
β βββ package.json
β βββ vite.config.js
β βββ tailwind.config.js
β βββ postcss.config.js
βββ docker-compose.yml # PostgreSQL container
βββ QUICKSTART.sh # Linux/Mac setup script
βββ QUICKSTART.bat # Windows setup script
βββ .gitignore
βββ README.md
# Create new Codespace from repository
# Or clone if working locally
git clone https://github.com/yourusername/mql5-algo-builder.git
cd mql5-algo-builderCreate the directory structure as shown above, then add all the code from the artifacts:
backend/app/__init__.py (empty file)
backend/app/main.py - Copy from "main.py - FastAPI Application Entry Point" artifact
backend/app/config.py - Copy from "config.py - Backend Configuration" artifact
backend/app/database.py - Copy from "database.py & models/strategy.py" artifact
backend/app/api/__init__.py (empty file)
backend/app/api/routes.py - Copy from "routes.py - API Endpoints" artifact
backend/app/services/__init__.py (empty file)
backend/app/services/mt5_service.py - Copy from "mt5_service.py" artifact
backend/app/services/mql5_generator.py - Copy from "mql5_generator.py" artifact
backend/app/services/backtest_engine.py - Copy from "backtest_engine.py" artifact
backend/migrations/init_db.sql - Copy from "init_db.sql" artifact
backend/requirements.txt - Copy from "requirements.txt" artifact
backend/.env.example:
APP_NAME=MQL5 Algo Bot Builder
DEBUG=True
HOST=0.0.0.0
PORT=8000
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/mql5_algobot
CORS_ORIGINS=http://localhost:3000,http://localhost:5173frontend/public/index.html - Copy from "index.html" artifact
frontend/src/index.js - Copy from "index.js" artifact
frontend/src/index.css - Copy from "index.css" artifact
frontend/src/App.jsx - Copy from "Complete App.jsx" artifact
frontend/src/components/Chart.jsx - Copy from "Chart.jsx" artifact
frontend/src/components/DrawingTools.jsx - Copy from "DrawingTools.jsx" artifact
frontend/src/components/StrategyBuilder.jsx - Copy from "StrategyBuilder.jsx" artifact
frontend/src/components/BacktestPanel.jsx - Copy from "BacktestPanel.jsx" artifact
frontend/src/components/CodePreview.jsx - Copy from "CodePreview.jsx" artifact
frontend/src/services/api.js - Copy from "api.js" artifact
frontend/src/services/websocket.js - Copy from "websocket.js" artifact
frontend/src/styles/terminal.css - Copy from "terminal.css" artifact
frontend/package.json - Copy from "package.json" artifact
frontend/vite.config.js, tailwind.config.js, postcss.config.js - Copy from config files artifact
docker-compose.yml - Copy from Docker configuration artifact
.gitignore - Copy from Docker configuration artifact
QUICKSTART.sh - Copy from QUICKSTART.sh artifact
QUICKSTART.bat - Copy from QUICKSTART.bat artifact
chmod +x QUICKSTART.sh
./QUICKSTART.shQUICKSTART.batcd backend
# Create virtual environment
python -m venv venv
# Activate (Linux/Mac)
source venv/bin/activate
# Activate (Windows)
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env
cp .env.example .env# Start PostgreSQL with Docker
docker-compose up -d postgres
# Wait 5 seconds for PostgreSQL to start
# Database migrations run automatically on first backend startcd frontend
# Install dependencies
npm install./run-all.shrun-all.batdocker-compose up postgrescd backend
source venv/bin/activate # Windows: venv\Scripts\activate
python -m app.maincd frontend
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
cd frontend
# Install Vercel CLI
npm install -g vercel
# Login
vercel login
# Deploy
vercel --prod
# Set environment variable in Vercel dashboard:
# VITE_API_URL=http://your-ngrok-url# Install ngrok
# https://ngrok.com/download
# Expose backend
ngrok http 8000
# Update CORS_ORIGINS in backend/.env with ngrok URL# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
# Initialize
railway init
# Add PostgreSQL
railway add
# Deploy
railway up
# Set environment variables in Railway dashboardcd frontend
vercel --prod
# Set VITE_API_URL to Railway backend URL- Start MT5: Ensure MetaTrader 5 is running and logged into Exness
- Check Status: Look for green "MT5: Connected" indicator in header
- Load Data: Enter symbol (EURUSD), select timeframe (H1), click "Load Data"
-
Name Strategy: Enter unique strategy name
-
Add Visual Elements:
- Click "Horizontal Line" button
- Select entry action (Buy Above/Sell Below)
- Click on chart at desired price level
- Repeat for multiple levels
-
Configure Risk:
- Set risk % per trade (default: 2%)
- Set stop loss in pips (e.g., 50)
- Set take profit in pips (e.g., 100)
-
Create: Click "Create Strategy" button
- Click "Backtest" tab
- Click "Run Backtest" button
- View performance metrics:
- Final Balance
- Win Rate
- Profit Factor
- Max Drawdown
- Trade history
- Click "MQL5 Code" tab
- Review generated code
- Click "Download .mq5"
- Copy to
MT5_DATA_FOLDER/MQL5/Experts/ - Open in MetaEditor
- Compile (F7)
- Attach to chart in MT5
- Open MetaEditor (F4 in MT5)
- File β Open Data Folder
- Navigate to
MQL5/Experts/ - Paste downloaded .mq5 file
- Right-click β Compile
- Check for errors in "Errors" tab
- Close MetaEditor
- In MT5: Navigator β Expert Advisors β Your Strategy
- Drag onto chart
- Configure inputs, enable AutoTrading
Problem: "MT5: Disconnected" status
Solutions:
- Ensure MT5 is running and logged in
- Check MetaTrader5 Python package:
pip install MetaTrader5 - Run Python as administrator if MT5 is admin
- Restart both MT5 and backend
Problem: Database errors in backend logs
Solutions:
- Check PostgreSQL is running:
docker-compose ps - Verify DATABASE_URL in
.env - Test connection:
psql -h localhost -U postgres -d mql5_algobot - Restart PostgreSQL:
docker-compose restart postgres
Problem: API errors, network failures
Solutions:
- Verify backend is running on port 8000
- Check CORS settings in
backend/app/config.py - Test API:
curl http://localhost:8000/health - Check browser console for errors
- Disable browser extensions (ad blockers)
Problem: Backtest fails or returns empty results
Solutions:
- Ensure chart data is loaded first
- Verify symbol exists in MT5
- Check date range has trading data
- Test with different timeframe
- Check backend logs for errors
Problem: Python module not found errors
Solutions:
cd backend
source venv/bin/activate
pip install -r requirements.txt --upgradeProblem: Port 8000 or 3000 already occupied
Solutions:
# Find process using port
# Linux/Mac:
lsof -i :8000
kill -9 <PID>
# Windows:
netstat -ano | findstr :8000
taskkill /PID <PID> /F
# Or change ports in configProblem: Chart appears empty or blank
Solutions:
- Check browser console for errors
- Verify data is loaded: Look at network tab
- Try different symbol or timeframe
- Clear browser cache
- Check Lightweight Charts is loaded
- Start with simple strategies (1-2 conditions)
- Test on demo account first
- Use conservative risk (1-2%)
- Backtest multiple timeframes
- Validate on different symbols
- Never risk more than 2% per trade
- Use stop losses always
- Maintain 1.5:1 or better R:R ratio
- Diversify across symbols
- Monitor max drawdown
- Review generated MQL5 code before deployment
- Test in Strategy Tester first
- Keep strategy logic simple
- Document your strategies
- Version control (Git)
- Load only necessary data
- Limit backtest date range
- Close unused strategies
- Monitor server resources
- Regular database maintenance
For issues:
- Check this troubleshooting section
- Review API documentation at
/docs - Check MT5 terminal logs
- Create GitHub issue with full error details
MIT License - See LICENSE file
Built for algorithmic traders who demand precision, speed, and visual clarity π