# Claude with MetaTrader 5: a safe, read-first setup

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/guides/claude-mt5, written from the same records as that page.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

There are two routes: MetaTrader 5's own AI and MCP support, where Anthropic is a selectable provider, or Claude writing Python for the MetaTrader5 package. Either way, start on demo, read before you trade and confirm every order yourself.

- Checked: 2026-09-18
- For: Non coders building with AI help
- About: [MetaTrader 5 (Python package and MQL5)](https://openbrokerapi.com/platforms/metatrader-5)

## Steps

### 1. MT5 has MCP and AI built in

Build 6060 (23 Jul 2026) added MCP support so external AI agents can use MetaTrader 5 as a market data and trading source, plus AI Assistants in the terminal and MetaEditor. Anthropic is one of the selectable providers alongside MQL5 Lite, OpenAI, Gemini, DeepSeek and Ollama.

Status: verified. Source: [metatrader5.com](https://www.metatrader5.com/en/releasenotes/terminal/2447), checked 2026-09-18.

### 2. Set AI trading to confirm or off

MetaQuotes says you can allow or prohibit AI initiated trading operations, or require manual confirmation. Pick prohibit while you learn, then manual confirmation.

Status: verified. Source: [metatrader5.com](https://www.metatrader5.com/en/releasenotes/terminal/2447), checked 2026-09-18.

### 3. Log in to a demo account

The MetaTrader5 Python package uses whichever account the running terminal is logged in to, so log the terminal in to demo. It needs Windows.

Status: verified. Source: [pypi.org](https://pypi.org/project/MetaTrader5/), checked 2026-09-18.

### 4. Ask Claude for read-only code

Ask Claude for a script that calls initialize(), reads account_info() and positions, and never calls order_send. Credentials stay in the terminal or in environment variables, never in the chat.

Status: verified. Source: [mql5.com](https://www.mql5.com/en/docs/python_metatrader5), checked 2026-09-18.

### 5. Keep a human in the loop

The MCP specification says there should always be a human in the loop who can deny tool calls, and clients should show tool inputs before calling a server. Approve each tool call in Claude rather than allowing all.

Status: verified. Source: [modelcontextprotocol.io](https://modelcontextprotocol.io/specification/2025-06-18/server/tools), checked 2026-09-18.

### 6. Community MCP server trades by default

The community metatrader-mcp-server connects Claude Desktop to MT5, takes LOGIN, PASSWORD and SERVER as arguments or environment variables, and enables its trading tools once configured. It is listed in our AI and MCP guide, not tested or endorsed; use it on demo only.

Status: verified. Source: [github.com](https://github.com/ariadng/metatrader-mcp-server), checked 2026-09-18.

### 7. Check success codes

If you later add orders, success is result.retcode equal to TRADE_RETCODE_DONE (10009); anything else is a failure to read, not retry blindly. Our MT5 error pages list the codes.

Status: verified. Source: [mql5.com](https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes), checked 2026-09-18.

## Sources

- Status: verified. Source: [MT5 Build 6060 release notes](https://www.metatrader5.com/en/releasenotes/terminal/2447), checked 2026-09-18.
- Status: verified. Source: [MQL5 docs: MetaTrader 5 for Python](https://www.mql5.com/en/docs/python_metatrader5), checked 2026-09-18.
- Status: verified. Source: [PyPI: MetaTrader5](https://pypi.org/project/MetaTrader5/), checked 2026-09-18.
- Status: verified. Source: [MCP specification 2025-06-18: Tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools), checked 2026-09-18.
- Status: verified. Source: [GitHub: ariadng/metatrader-mcp-server (community)](https://github.com/ariadng/metatrader-mcp-server), checked 2026-09-18.
- Status: verified. Source: [MQL5 docs: trade server return codes](https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes), checked 2026-09-18.

## More on the MetaTrader 5 API

- [MetaTrader 5 API quickstart](https://openbrokerapi.com/platforms/metatrader-5/quickstart): From credentials to a first call on a demo account, step by step.
- [MetaTrader 5 API error codes](https://openbrokerapi.com/errors/mt5): 311 decoded, each with what it means, and the fix where the source gives one.
- [MetaTrader 5 functions](https://openbrokerapi.com/platforms/metatrader-5/functions): 78 documented, each with its signature, arguments, return value and source.
- [MetaTrader 5 API page](https://openbrokerapi.com/platforms/metatrader-5): The full record: access, authentication, limits and the source for each.
- [MetaTrader 5 for Python: which platforms does it run on?](https://openbrokerapi.com/guides/metatrader-5-python-platforms): Guide
- [MT5 trade history to a spreadsheet with Python](https://openbrokerapi.com/guides/mt5-trade-history-to-a-spreadsheet): Guide

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: Claude with MetaTrader 5: a safe, read-first setup. Broker API Hub, https://openbrokerapi.com/guides/claude-mt5, newest check 2026-09-18.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
