An advanced, real-time AI-powered trading platform that bridges MetaTrader 5 (MT5), a FastAPI backend, and a Local LLM (Ollama) to deliver institutional-grade market intelligence, visual analytics, and autonomous trade execution.
- Ollama Integration: Uses local models (like
llama3:8b) to prevent data leakage and ensure zero latency in signal processing. - AI Decision Engine: Multi-agent debate simulation and RAG (Retrieval-Augmented Generation) context handling for robust signal validation.
- Pattern Recognition: Automated detection of chart patterns analyzed by AI.
- Real-Time Charting: High-performance canvas charting with live candle updates via WebSockets.
- Volume Profile & TPO: Visualize volume nodes, POC (Point of Control), VAH, and VAL.
- Multi-Timeframe Analysis: Instant trend bias and indicator alignment from M1 to Weekly.
- Advanced Indicators Panel: Parity with MT5 including Bollinger Bands, EMAs, Williams %R, SAR, and more.
- Direct MQL5 Bridge: No middleman DLLs. Native
WebRequestcommunication. - Live Account Telemetry: Real-time tracking of Balance, Equity, Margin Level, and floating P/L.
- Drawings Sync: Server-side drawings pushed directly to your MT5 chart.
graph TD
A[MT5 Terminal / MQL5 EA] -->|REST POST / Updates| B(FastAPI Backend)
B -->|WebSockets| C[Web Frontend Dashboard]
B -->|Async SQLite| D[(Database)]
B -->|Local API| E[Ollama LLM]
C -->|REST POST / Orders| B
B -->|Queued Signals| A
- Python: 3.10 or higher
- MetaTrader 5: Installed and logged into an account.
- Ollama: Installed locally.
- Navigate to the backend directory:
cd backend - Install dependencies:
pip install -r requirements.txt
- Ensure Ollama is running and has the required model:
ollama run llama3:8b
- Start the server:
The server will run on
python server.py
http://localhost:8000.
- Open MT5 and go to
Tools -> Options -> Expert Advisors. - Check "Allow WebRequest for listed URL" and add:
http://localhost:8000 - Open the MQL5 folder in your project.
- Copy
AiTrader.mq5to your MT5MQL5/Expertsdirectory. - Compile and attach the EA to a chart (e.g., BTCUSD).
- The frontend is served by the FastAPI backend.
- Open your browser and navigate to
http://localhost:8000.
- Backend: FastAPI, SQLAlchemy, Pydantic, Uvicorn, HTTPX
- Frontend: Vanilla JS, HTML5, Tailwind CSS, Lightweight Charts (TradingView)
- Database: SQLite (WAL mode for async performance)
- AI: Ollama (Local LLM), ChromaDB (Vector Search)
- Trading: MQL5 (MetaQuotes Language 5)
algorithmic-trading quantitative-finance fastapi mql5 ollama ai-trading tradingview lightweight-charts python real-time metatrader5 local-ai
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to contribute to this project! Open an issue or submit a pull request.