A complete bridge system that connects MetaTrader 5 to modern web applications through REST APIs and WebSocket streaming. Built with MQL5, Node.js, and React.
MT5 Bridge enables external applications to interact with MetaTrader 5 in real-time by exposing trading and market data through a multi-layer architecture:
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β React β HTTP β Node.js β HTTP β MT5 EA β
β Dashboard βββββββββΆβ Backend βββββββββΆβSocketBridge β
β (Port 8002) β :8891 β (Port 8891) β :8890 β (Port 8890) β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β
β β
ββββββββββββββββ WebSocket ββββββββββββββββββββββββ
(Direct Connection)
- π Real-Time Streaming β WebSocket connection for live price updates
- π REST API β Complete HTTP API for trading and account management
- π Market Data β Access to prices, quotes, and symbol information
- π° Account Management β Real-time balance, equity, and margin data
- π Order Management β Place, modify, and close orders programmatically
- π Price History β Historical data with interactive charts
- π€ CSV Export β Export market data for analysis
- π Lightweight β No external dependencies, runs entirely within MT5
The project consists of four main components:
1. MetaTrader 5 Expert Advisor β π Documentation
An embedded HTTP and WebSocket server that runs inside the MT5 terminal, exposing trading and market data through REST API (port 8890) and WebSocket connections.
2. Node.js Backend β π Documentation
A TypeScript-based middleware that proxies requests between the frontend and MT5 EA, providing Swagger documentation and error handling (port 8891).
3. React Dashboard β π Documentation
A testing and demonstration interface with live charts, account monitoring, order management, and CSV export capabilities.
4. MT5 Docker Container β π Documentation
A Dockerized Debian XFCE environment with VNC/NoVNC access, pre-configured with Wine and MetaTrader 5. Access the desktop via browser at http://localhost:6080.
- MetaTrader 5 terminal (build 3000+)
- Node.js 18+ or Docker
- npm or yarn
-
Clone the repository
git clone https://github.com/mobjoy0/mt5-bridge.git cd mt5-bridge -
Setup MT5 Expert Advisor
# Copy files to MT5 data folder # MQL5/Experts/SocketBridge/ # MQL5/Include/SocketBridge/ # Compile in MetaEditor and attach to any chart # Enable AutoTrading in MT5
-
Setup Node.js Backend
cd web/mt_nodejs npm install npm run dev -
Setup React Dashboard
cd web/mt5react npm install npm run dev -
Access the Dashboard
http://localhost:8002
# Build and run with Docker Compose
docker-compose up -d
# Access the services
# Node.js Backend: http://localhost:8891
# React Dashboard: http://localhost:8002
# MetaTrader 5 (VNC / NoVNC): http://localhost:6080After the MT5 container is running, please refer to Documentation for instructions on installing and setting up MetaTrader 5 inside the container.
Detailed documentation for each component:
- MQL5 Expert Advisor β Setup, REST endpoints, WebSocket protocol
- Node.js Backend β Installation, configuration, Swagger API docs
- React Dashboard β Features and usage
- MT5 Docker Container β VNC setup, Wine configuration, first-time installation
Interactive API Documentation: http://localhost:8891/api-docs (when running)
The bridge provides REST API and WebSocket streaming for MT5 integration.
REST Base URL: http://localhost:8891/api/v1
WebSocket URL: ws://localhost:8890
For complete API reference, see the MQL5 EA Documentation or access the Swagger UI at http://localhost:8891/api-docs.
- Algorithmic Trading Bots β Execute automated strategies from external systems
- Custom Trading Dashboards β Build web-based interfaces for MT5
- Risk Management Tools β Monitor positions and account metrics in real-time
- Trade Analytics β Export and analyze trading data
- Mobile Trading Apps β Connect mobile apps to MT5 via the API
- Trading Signal Distribution β Broadcast trades to multiple accounts
| Component | Technologies |
|---|---|
| MT5 EA | MQL5 |
| Backend | Node.js, TypeScript, Express, Swagger |
| Frontend | React, TypeScript, Vite, Lightweight Charts, ApexCharts |
| Communication | REST API, WebSocket (RFC 6455) |
Contributions are welcome! Here are some areas where you can help:
- π¨ UI/UX Improvements β Enhance the React dashboard
- π± Mobile Support β Responsive design and mobile app
- π§ͺ Testing β Unit and integration tests
- π Advanced Features β Technical indicators, backtesting, etc.
- π Internationalization β Multi-language support
- π Documentation β Improve guides and examples
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Never expose your MT5 EA ports (8890, 8891) to the public internet without proper authentication
- Use this system on demo accounts for testing before live trading
- Always implement proper risk management
This software is provided for educational and development purposes. Use at your own risk. Always test thoroughly on a demo account before deploying to live trading environments. Trading involves substantial risk of loss.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project useful, please consider giving it a β on GitHub!
Made with β€οΈ for the trading community