Orders, end to end
Market, limit and stop orders with stop loss, take profit, magic number and comment. Modify them, close them fully or partly, and list everything open or pending.
MetaPortAPI is a lightweight Expert Advisor that lets any script or app read prices, send orders and stream market data from MetaTrader 5 — in the language you already use, on the machine you already trust.
$ curl "http://127.0.0.1:81/v1/quote?symbol=XAUUSD" {"MSG":"QUOTE","SYMBOL":"XAUUSD","ASK":4047.716, "BID":4047.548,"FLAGS":6,"TIME":"2026.10.28 08:04:58.326", "VOLUME":0,"ERROR_ID":0, "ERROR_DESCRIPTION":"The operation completed successfully"}
Market, limit and stop orders with stop loss, take profit, magic number and comment. Modify them, close them fully or partly, and list everything open or pending.
Ticks, OHLC bars, depth of market and trade events pushed over WebSocket the moment they happen.
ws://127.0.0.1:81Bid, ask and tick time for any symbol your broker offers.
Moving averages, ATR, or any custom indicator you have installed — values straight from the terminal.
Closed positions, deals and orders by date, plus candle and tick history for research and backtests.
Balance, equity and margin; full symbol specifications and trading sessions; economic calendar events by currency or country.
Demo-only trading mode and localhost-only access are on by default, and you can set a maximum lot per order. You decide when to switch them off.
MetaPortAPI runs inside your terminal and opens local ports. Your code sends a request, the EA carries it out in MT5 and answers in JSON.
Any language, on Windows, Linux or mobile.
Orders use the terminal's own connection — nothing reverse-engineered.
Your strategy and account data never pass through a third-party cloud.
Requests stay on your machine or VPS, so latency is the terminal's own.
OpenAPI 3 spec, plain JSON, curl-friendly. No MQL5 needed on your side.
Run one terminal per account on different ports for hedging, arbitrage or copy trading.
import requests
API = "http://127.0.0.1:81"
# current price
q = requests.get(f"{API}/v1/quote", params={"symbol": "XAUUSD"}).json()
print(q["BID"], q["ASK"])
# buy 0.05 lot (demo account)
r = requests.post(f"{API}/v1/order",
params={"symbol": "XAUUSD", "volume": 0.05,
"type": "ORDER_TYPE_BUY"}).json()
print(r["RETCODE"], r["ORDER"])using var http = new HttpClient { BaseAddress = new Uri("http://127.0.0.1:81") };
var quote = await http.GetStringAsync("/v1/quote?symbol=XAUUSD");
Console.WriteLine(quote);
var order = await http.PostAsync(
"/v1/order?symbol=XAUUSD&volume=0.05&type=ORDER_TYPE_BUY", null);
Console.WriteLine(await order.Content.ReadAsStringAsync());const API = "http://127.0.0.1:81";
const q = await fetch(`${API}/v1/quote?symbol=XAUUSD`).then((r) => r.json());
console.log(q.BID, q.ASK);
// live ticks over WebSocket
await fetch(`${API}/v1/track/prices?symbols=XAUUSD,EURUSD`, { method: "POST" });
const ws = new WebSocket("ws://127.0.0.1:81");
ws.onmessage = (e) => console.log(JSON.parse(e.data));$api = "http://127.0.0.1:81"
Invoke-RestMethod "$api/v1/quote?symbol=XAUUSD"
Invoke-RestMethod -Method Post `
"$api/v1/order?symbol=XAUUSD&volume=0.05&type=ORDER_TYPE_BUY"Every feature works free on demo accounts in 7-hour sessions. Upgrade when you are ready to trade a live account.