A MetaTrader API for prop firm tools, on MT4 and MT5
Tickwire gives prop firm tools a MetaTrader API: stream equity on many MT4 and MT5 accounts, count days on the broker's clock, hear when an account can't be seen, and close positions with one idempotent call. Your code sets the rules. Tickwire runs the terminals and tells you the truth about each one.
A risk tool has one job: never miss a breach
That means knowing when you can't see an account, not only when it's losing. Five steps cover it.
- Connect with the investor password. To only watch, connect each trader's account with its investor (read-only) password. Use the master password only on accounts you must be able to flatten.
- Stream equity. One WebSocket per account sends balance, equity and positions as they change. Nothing to poll.
- Count days on the broker's clock. Daily loss limits usually reset at the broker's midnight, not UTC. Take the start-of-day balance at the broker's day change.
- Know when you're blind. Register a webhook for account.health_changed. A disconnected account isn't protected, so show that, not the last equity.
- Flatten, then verify. On a breach, close with one idempotent call, then read positions until they're empty.
Stream equity, and spot blind spots
The account stream sends a full sync, then each change. Health frames come on the same socket, so your tool knows the moment it stops seeing an account.
const ws = new WebSocket(`wss://api.tickwire.io/users/current/accounts/${id}/ws?auth-token=${token}`);
ws.onopen = () => ws.send(JSON.stringify({ type: "subscribe" }));
ws.onmessage = (m) => {
const f = JSON.parse(m.data);
if (f.type === "accountInformation" || f.type === "accountInformationUpdated") {
check(id, f.accountInformation.equity, f.accountInformation.balance);
}
if (f.type === "health" && f.health.status !== "healthy") notWatching(id, f);
};
Browsers can't set headers on a WebSocket, so give a browser a short-lived scoped token, never a full key.
Keep the sessionId and last seq to resume after a drop. See
Streaming.
Flatten on breach
POST /v1/orders/close closes by selector on up to 20 accounts in one call. The
Idempotency-Key holds the account and the broker date, so a repeat can never close twice.
curl -s -X POST "https://api.tickwire.io/v1/orders/close" \
-H "X-API-Key: $TW_KEY" \
-H "Idempotency-Key: breach-acc_A1-2026-10-25" \
-H "X-Actor: risk-engine" -H "X-Reason: daily loss 5% breached" \
-H "content-type: application/json" \
-d '{"accounts": [{"account_id": "acc_A1", "symbol": "*", "kind": "any"}]}'
Then read positions until it's empty. An account answer of timeout means positions
may have closed: read positions, orders and deals before you do anything else. See
Idempotency.
Why truthful health matters here
- Connected means logged in. It means the terminal is logged in and the account was read, not that a process is running.
- Unknown is a real answer. When Tickwire can't tell, it says
unknown. - Webhooks for the bad moments. Disconnects, failed logins, margin calls and stop-outs arrive as signed webhooks.
- A log of every change, with the actor and the reason, for every close your tool sends.
Addresses
Accounts run on a shared address at $12 an account a month. You can put any of them on an own address, at $14 an account for those accounts; the rest stay at $12. A dedicated IP belongs to one customer for life and is never given to anyone else.
It does not make a strategy meet any firm's rules. Read your firm's written terms. Our post on prop firm accounts and your IP address explains the difference.
Questions
Is there a MetaTrader API for prop firm tools?
Yes. Tickwire hosts a real MT4 or MT5 terminal for each account and gives you REST, WebSocket and webhooks. A prop tool can stream equity on many accounts, apply its own drawdown rules and close positions when a rule is broken.
Can I monitor accounts with the investor password?
Yes. Connect with the investor password and the account is read-only at the broker: you see balance, equity, positions and history, and no trade can be placed. Use the master password only where your tool must flatten.
Does Tickwire enforce drawdown rules for me?
Not through the public API yet. Today you enforce the rule from your own code: stream equity, compare it with your limit, and close positions with an idempotent call. The guide shows each step.
How do daily loss limits handle time zones?
Most firms reset the day at the broker's midnight. Tickwire labels broker time and never passes it off as UTC, so you can take the start-of-day balance at the broker's day change.
How do I close every position on many accounts at once?
Send POST /v1/orders/close with up to 20 accounts. Each entry is a selector: a symbol or * for all, plus optional side, kind or magic number. Then read positions to confirm. If a close comes back as timeout, read before you retry.
Can each trader's accounts have their own IP address?
You choose an own address per account. On Starter, the accounts you put on it are $14 an account a month; the rest stay at $12. A dedicated address is only ever used by one customer and is never given to anyone else. Whether it meets a firm's rules is for that firm to say.
Does it work on MT4 and MT5?
Yes. Both share the same API. A few MT5-only features, such as market depth, answer not_supported_on_mt4 on MT4. Equity, positions and closes work on both.
The MT5 API
The MT4 API
Copy trading API
What the API costs per account
Build your risk tool
7-day free trial. Then from $12 per account a month. See pricing. Test on a demo account first.