metatrader-mcp-server
Allows automated trading by processing TradingView Pine Script strategy alerts via webhook, enabling market order execution with custom stop loss and take profit levels in MetaTrader 5.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
๐ Riffmax-TradingBot-AI-RiffEx
Autonomous AI Trading Agent powered by Python and MetaTrader 5 (MT5) MCP โ real-time market structure analysis, automated signal generation, intelligent order execution, and strict risk guardrails.
๐ What it does
Riffmax-TradingBot-AI-RiffEx is an autonomous trading agent that operates directly on MetaTrader 5 (MT5) using Python and the Model Context Protocol (MCP):
๐ Real-Time Market Analysis โ Ingests live tick data, OHLCV candles, order books, and open positions directly through MT5 MCP tools.
๐ง AI Decision Engine โ Analyzes price action, market liquidity, and volatility metrics using Python-based quantitative models and LLM agent reasoning.
โก Direct Order Execution โ Places, tracks, modifies, and closes market and pending orders programmatically via the MT5 MCP interface.
๐ก๏ธ Autonomous Risk Guardrails โ Enforces dynamic lot sizing based on account equity, automatic stop-loss (SL), take-profit (TP), maximum drawdown thresholds, and spread filtering.
๐ Structured Logging & Auditing โ Records all signal evaluations, execution payloads, and deal receipts in JSON/CSV audit trails.
Related MCP server: MetaTrader 5 MCP Server
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI Agent Decision Layer (Python) โ
โ โข Technical Analysis โข Price Action โข Volatility โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
Model Context Protocol (MCP)
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MT5 MCP Server โ
โ โข get_candles_latest โข get_account_info โ
โ โข place_market_order โข modify_position โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MetaTrader 5 (MT5) Terminal โ
โ Broker Execution ยท Live Market Liquidity โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๐ ๏ธ Stack
Component | Technology | Description |
Language | Python 3.10+ | Core trading engine and quantitative analysis |
Execution Protocol | MT5 Model Context Protocol (MCP) | Tool-based interface for market data & order dispatch |
Broker Platform | MetaTrader 5 (MT5) | Multi-asset execution terminal (Forex, Indices, Crypto) |
Data Processing | NumPy, Pandas | Candle parsing, moving averages, volatility metrics |
Risk Management | Custom Python Engine | Lot sizing, trailing stops, daily loss limits |
Configuration |
| Secure credential isolation |
๐ Quick Start
Prerequisites
Python 3.10+
MetaTrader 5 terminal installed and logged into your broker account
MT5 MCP server configured
1. Clone & Install
git clone https://github.com/Riffmax2030-hub/Riffmax-TradingBot-AI-RiffEx.git
cd Riffmax-TradingBot-AI-RiffEx
pip install -r requirements.txt2. Configure Environment
cp .env.example .env
# Edit .env with your credentials โ NEVER commit real .env files.env.example template:
MT5_ACCOUNT=your_account_number
MT5_PASSWORD=your_password
MT5_SERVER=your_broker_server
MAX_RISK_PER_TRADE_PERCENT=1.0
MAX_DAILY_DRAWDOWN_PERCENT=3.03. Run the Trading Agent
python main.py๐ Project Structure
Riffmax-TradingBot-AI-RiffEx/
โโโ agent/
โ โโโ market_analyzer.py # Price action & indicator analysis
โ โโโ decision_engine.py # Signal generation logic
โ โโโ mcp_bridge.py # MT5 Model Context Protocol interface
โ โโโ risk_guard.py # Dynamic lot sizing & risk limits
โโโ config/
โ โโโ config.yaml # Symbol lists, timeframe, max spread
โโโ logs/ # Trade logs & audit trails (gitignored)
โโโ tests/
โ โโโ test_market_analyzer.py
โ โโโ test_risk_guard.py
โโโ .env.example # Template with placeholders
โโโ .gitignore # Excludes credentials, logs, caches
โโโ requirements.txt
โโโ README.md๐ Security & Risk Disclaimer
Financial & Credential Security:
Never hardcode broker account numbers, server details, or passwords in code or commits.
All sensitive configurations are loaded strictly via environment variables.
Trading financial markets carries risk. Use a demo account for testing before any live deployment.
๐ License
MIT ยฉ Sherif Akanmu
This server cannot be deployed
Maintenance
Related MCP Connectors
Let AI agents trade and read MetaTrader 5 accounts. Hosted โ no terminal for you to run.
Read-only access to your MetaTrader 4 and 5 accounts for AI agents: balances, open positions, trade history with win rate, live quotes, symbol specs and candles. It cannot place, modify or close orders.
Trade 16 crypto exchanges + MetaTrader 5 from your AI assistant via one MCP connection.
Connect any MCP client to MetaTrader 4/5 to read prices, manage positions, and place trades.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with the MetaTrader 5 trading platform for market data analysis, placing trades, and managing trading positions. Provides comprehensive access to forex and financial market operations through the Model Context Protocol.1-
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to connect to MetaTrader 5 for trading, market data access, and account management through the Model Context Protocol.116 PyPI238MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to trade on MetaTrader 5 using natural language, supporting account management, order placement, and real-time market data.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables read and execution access to multiple MetaTrader 5 accounts, allowing an AI assistant to manage positions, P&L, prices, indicators, history, logs, and trades across accounts.1MIT