Cover photo

How I Taught AI to Control the Terminal

A Non-Technical Guide to the MT5 Bridge


You know that friend who somehow lands a job at a fancy company but speaks only Swahili, while everyone else speaks French? And instead of firing him, the company hires a translator to sit between him and the rest of the staff?

That is, more or less, what the MT5 Bridge is.

Let me explain.


The Cast of Characters

MetaTrader 5 (MT5) is professional trading software used by traders worldwide to watch markets, draw lines on charts, and pretend they know what price is going to do next. It's powerful, it's been around forever, and it speaks its own private language called MQL5. It's also — and this is important — a Windows application being forced to run on a Mac through a compatibility layer called Wine, which is a bit like making a cat wear a dog costume. It mostly works. Mostly.

Claude (or any AI agent, really) is a large language model. It's very clever, speaks fluent JSON and TypeScript, and can reason about markets given the right data. The problem? It has no idea MetaTrader 5 exists. It can't look at your charts. It cannot click things. It lives in a conversation window and knows nothing about what's happening on your screen.

The MT5 Bridge is the translator hired to fix this exact problem.


The Problem, Illustrated

Imagine you have a brilliant research analyst (the AI) locked in a room with no windows, no internet, and no Bloomberg terminal. You also have a full trading workstation (MT5) in the next room, running live, connected to every market on Earth.

These two need to talk. They cannot. One speaks HTTP and JSON. The other speaks MQL5 and runs inside a Windows emulator on a Mac.

The Bridge is the connecting corridor — a tiny web server that runs quietly in the background, accepting instructions from the AI in plain English-ish (JSON, actually), and passing them through to MT5, which then does the actual work and reports back.


How It Actually Works

Here's the flow, stripped of all jargon:

  1. The AI decides it wants to know the price of EURUSD.

  2. It sends a message to the Bridge — a small local web server running on your machine — saying something like: "Hey, get me the price of EURUSD."

  3. The Bridge writes that request on a notepad (a command queue) and waits.

  4. Inside MT5, there's a tiny program called an Expert Advisor (EA) — think of it as a very obedient intern who checks the notepad every 25 milliseconds (that's 40 times per second, which is genuinely more diligent than any human intern). It sees the request, walks over to the MT5 market data desk, fetches the price, and posts the answer back to the Bridge.

  5. The Bridge hands the answer back to the AI Agent aka claude, openclaw, etc.

  6. The AI now knows the price of EURUSD. It continues its analysis, probably draws a trend line, asks for a screenshot, and generally acts like it has been doing this for years.

The whole round trip — from "what's the price?" to "here it is" — takes about 55 milliseconds on average. That's faster than a human blink, which is 100–400ms. The AI is, in this narrow sense, faster than you.


What Can the AI Actually Do?

Once connected, the AI can do a surprising amount of things inside MT5 — all without you touching the keyboard:

Read the markets: It can fetch the live bid/ask price of any symbol — currencies, indices, crypto, metals. It can pull historical price bars (the open, high, low, close data that makes up every chart candle). It can see your entire list of 500+ tradable instruments, neatly categorized.

See your account: Balance, equity, margin used, free margin, open profit. Everything your broker knows about you, the AI can know too.

Control the charts: It can open a new chart window, close one, switch a chart from EURUSD to GBPUSD, apply your saved templates, and — perhaps most impressively — draw things directly onto the chart:

  • Horizontal lines at key price levels (with automatic price alerts baked in)

  • Trend lines between two points in time

  • Vertical lines marking important dates or events

  • Rectangles shading supply and demand zones

  • And it can clean all of that up when it's done

Take screenshots: It can snap a PNG of any chart at whatever resolution you like (up to 1920×1080 and beyond) and save it to disk — useful for logging analysis, building reports, or just documenting "I told you price was going to reject that level."

Check positions and orders: What trades are currently open? What pending orders are sitting in the queue? The AI knows.


The Bit Where We Talk About Wine (Not the Drinking Kind)

MT5 is a Windows application. The person who built this runs a Mac. Rather than buying a Windows machine, they use Wine — software that lets Mac run Windows programs by translating Windows commands into Mac commands in real time, which is engineering witchcraft and somehow mostly works.

The practical consequence is a small tax on speed. Every command has to make a round trip through this translation layer, which adds about 53ms of unavoidable delay. The Bridge is smart enough to poll at exactly the right interval — every 25ms — to keep latency as low as physically possible without wasting CPU cycles hammering at a wall that won't respond any faster.

This is a solved problem. It's mentioned here only so you understand why the speed numbers look the way they do.


Why Does Any of This Matter?

Because a trading terminal full of data is only useful if someone (or something) is watching it, interpreting it, and acting on it.

Humans are good at intuition but bad at consistency. We get tired. We get emotional. We miss things. We go to lunch.

An AI agent connected to a live MT5 terminal doesn't go to lunch. It can be asked, at any moment, to pull the last 100 hourly candles for a dozen symbols, calculate whatever it needs to calculate, draw the conclusions on the chart, take a screenshot, and send a summary — all in under two seconds.

The MT5 Bridge is what makes that possible. It's not glamorous. It's just a very efficient translator sitting in a corridor between two systems that would otherwise have nothing to say to each other.


The Summary, For People Who Skipped to the End

  • MetaTrader 5 is professional trading software. Very capable. Speaks its own language.

  • AI agents (like Claude) are smart but blind — they can't see your charts or touch your terminal.

  • The MT5 Bridge is a local web server that translates between them.

  • An Expert Advisor inside MT5 checks for instructions 40 times per second like a very caffeinated intern.

  • Together, they let an AI read prices, control charts, draw analysis, and monitor your account — all programmatically, all automatically, all in about 55 milliseconds per command.

The AI can now stare at the charts.

You can go touch some grass.


Built with TypeScript, Express, MQL5, a healthy respect for latency budgets, and an unreasonable amount of patience for Wine.