TraderWAI
PlatformsAIsDocsBlogPricing
Sign inStart free
All posts
GuidesNovember 27, 2026· 6 min read

How to connect Claude Code to MetaTrader 5 (MT5)

Add TraderWAI to Claude Code with one command and let it read your MT5 account, live charts and your broker's prices, run backtests and place orders inside the limits you set. No EA, no code to maintain.

Gold chart marked up by the AIYour AI analyses, draws on the chart and trades on your broker. Free, no card.Connect your AI freeNo broker yet? Try it free with a simulated account: your AI trades with virtual money and real prices. How to connect Claude Code to MetaTrader 5 (MT5)

Claude Code lives in your terminal and your editor: it reads files, runs commands and writes code. What it can't do on its own is see your MetaTrader 5 account. TraderWAI adds that with one MCP server: Claude Code reads your MT5 balance and positions, gets your broker's live price, draws levels on a real chart, backtests an idea on minute data and places orders sized from your risk, always inside the limits you set on the TraderWAI website.

There is no Expert Advisor to install and no MetaTrader to keep open. TraderWAI connects to your broker's MT5 server from the cloud.

This guide is for Claude Code, the agent you run with claude. If you use Claude in the browser or the desktop app, follow Claude + MetaTrader 5 instead: same account, different setup.

What you need

  • Claude Code installed and signed in (it works with a Claude subscription or an API account).
  • An MT5 account, demo or live: the login (account number), the master password and the server name exactly as MetaTrader shows it. MetaTrader 4 works the same way.
  • A TraderWAI account on the Trader or Max plan. MetaTrader is available on Trader (5 accounts) and Max (10 accounts), and any of them can be MetaTrader. Charts, analysis and backtests are free on every plan, and the first paid month is 50% off. See pricing.

Step 1: add the MCP server to Claude Code

Run this in your terminal:

claude mcp add --transport http traderwai https://mcp.traderwai.com

Add --scope user if you want TraderWAI in every project, not just the current folder.

Then start Claude Code, type /mcp, choose traderwai and Authenticate. Your browser opens: sign in with Google or Microsoft and authorize access. There is no API key to paste or commit to your repo: access goes through OAuth, and your TraderWAI account is created on that first sign-in.

Step 2: connect your MT5 account

  1. In TraderWAI go to Settings → Brokers → Add account → MetaTrader.
  2. Enter the login, the master password and the server exactly as in MT5 (for example ICMarketsSC-Demo). You find it in MetaTrader under File → Login to Trade Account.
  3. Save. The first connection takes 1 to 3 minutes while the terminal is prepared in the cloud; after that it's instant.

Start with a demo account. Everything works the same, and you see how Claude Code behaves before real money is involved. Your password is stored encrypted and is never shown to the AI.

Step 3: what to ask

Claude Code shows each tool call and, by default, asks before running it, so you always see what is sent.

Read the market (no trades)

"Use TraderWAI. Get the XAUUSD H4 chart and the last day of M15 candles. Tell me the trend and the nearest support and resistance, and draw them on the chart. Don't place anything."

Your account and your broker's price

"Call get_broker_accounts and tell me which one is my MT5 demo. Then get_quote for EURUSD on that account: bid, ask and spread."

Backtest before you trade

"Backtest on EURUSD M15 over the last 3 months: buy the break of the Asian range high during London, stop below the range, take profit at 2R. Save the results to backtests/london-breakout.md."

backtest_strategy runs on TraderWAI's servers with real minute data; Claude Code is good at the part around it: comparing variants, writing the notes and keeping them in your repo.

An order sized by risk

"On my MT5 demo, buy EURUSD at market, stop loss at 1.0790, take profit at 2R, risking 0.5%. Show me the full order before you send it."

TraderWAI sizes the trade with your account currency and the symbol's contract specs and checks your risk limits before the order reaches MT5. If a limit blocks it, the tool returns RISK_LIMIT and nothing is placed. Orders carry a stop loss by default: Claude Code only sends one without it if you explicitly ask, and accounts with a risk-per-trade limit always require it.

Rules that run without you

"Create a conditional order on my EURUSD position: when it reaches 1R in profit, move the stop to break-even."

Conditional orders are checked every minute on TraderWAI's servers, so they keep working after you close the terminal.

Step 4: guardrails in CLAUDE.md and settings

Claude Code reads CLAUDE.md at the start of every session. Put your trading rules there:

# Trading MT5 with TraderWAI

- Use my MT5 demo account unless I name a live account in this session.
  Call get_broker_accounts first and say which account you will use.
- Before execute_trade, modify_position, close_position or
  create_conditional_order, show me: account, symbol, side, entry,
  stop loss, take profit and size. Wait for my explicit "yes".
- Always use a stop loss. Size by risk, at most 0.5% per trade.
- If a tool returns RISK_LIMIT or PLAN_LIMIT, stop and explain.
  Never retry or work around it.
- Use backtest_strategy for backtests; never compute them yourself.

Then make the order tools always ask, in .claude/settings.json:

{
  "permissions": {
    "ask": [
      "mcp__traderwai__execute_trade",
      "mcp__traderwai__execute_trade_multi",
      "mcp__traderwai__close_position",
      "mcp__traderwai__modify_position"
    ]
  }
}

CLAUDE.md and Claude Code's own permission prompt are two separate locks. Your risk limits on TraderWAI are the third, and the AI can read them but never change them.

Suggested orders instead of direct orders

If you prefer to decide every trade yourself, ask Claude Code to use suggest_order instead of execute_trade. The suggestion says which accounts and the size on each one, plus entry, stop loss, take profit and an expiry. Then, account by account, it waits for your authorization in TraderWAI, or it's placed right away only where you allowed auto-execution for that symbol and size (Settings → Auto-execution, paid plans). The size is never reduced to make it fit.

Troubleshooting

  • `/mcp` shows traderwai as failed or needing auth. Choose it and run Authenticate again; check that the URL is exactly https://mcp.traderwai.com.
  • "The MetaTrader server was not found". The server name must match MT5 character by character, including -Demo, -Live or the number. Copy it from the MT5 login window.
  • "MetaTrader rejected the login or password". Use the master password; the investor password is read-only. Connection attempts are limited to a few per day, so check the data before retrying.
  • Symbol suffixes like EURUSD.r or XAUUSD+ are mapped automatically: write EURUSD in your prompts.
  • `PLAN_LIMIT` on MetaTrader. MT4/MT5 needs Trader or Max. On Free you can try the same flow with a cTrader or TradeLocker demo.

Common questions

Do I need MetaTrader open? No. The connection runs in the cloud; your terminal and computer can be off.

Does Claude Code see my MT5 password? No. It's stored encrypted on TraderWAI and never shown to the AI.

What's the difference with Claude in the browser? The account and the tools are the same. Claude Code adds your files and your terminal: it can keep backtest notes and a trading journal in your repo and combine TraderWAI with your own scripts.

Can it trade while I'm away? Only within what you allowed: conditional orders run every minute on our servers, and suggested orders execute only on the accounts, symbols and sizes you permitted. Everything else waits for you.

Other editors? The same setup works in Cursor: see Cursor + MetaTrader 5. To backtest from any AI, read backtest a strategy with AI, and for the browser version of Claude, the Claude + MT5 quick guide.

Trading CFDs and forex involves a high risk of losing money. TraderWAI is a technology tool: it does not provide investment advice, AI analysis is not a recommendation and past results, including backtests, don't guarantee future results. You decide every order.

Try it with your own AI

Connect Claude or ChatGPT to your broker in a few minutes. Free plan, no card.

Start free

Questions or ideas? Talk with us in our Telegram community

Trading leveraged products carries a high risk of loss. TraderWAI is a technology tool: it is not investment advice and it is not a broker.

Keep reading

Guides
MT4 MCP server: connect MetaTrader 4 to Claude, ChatGPT, Grok or Gemini
Guides
Grok Bot for traders: backtest the idea before your bot trades it
TraderWAI

Connect any AI to your broker, with you in control.

Product
  • Platforms
  • AIs
  • Pricing
  • Docs
  • Status
  • Sign in
Resources
  • Connection guides
  • Broker guides
  • Best MCP servers for trading
  • Strategy backtests
  • Markets today
  • FAQ
  • Blog
  • Telegram community: questions & ideas
Company
  • Investors
  • Contact
  • Brokers and prop firms
Legal
  • Privacy
  • Terms

Trading leveraged products such as CFDs, forex and futures carries a high risk of losing money. TraderWAI is a technology tool: it does not provide investment advice and does not manage funds. The AI's analyses and proposals are not recommendations; you decide every order.

© 2026 TraderWAI · FLEXIN AGILE LTD