MT5 API guides for developers
Working notes on connecting MetaTrader 5 to real software — REST endpoints, webhook delivery, copy-trading mechanics, and the constraints that actually bite in production.
- 9 min read
MT5 retcodes explained: why your order was rejected
A field guide to MT5 retcodes organised by the fix: invalid stops, invalid volume, not enough money, requotes, market closed, bad expiration and the rest.
MetaTrader 5MT5 APIOrder ExecutionTroubleshooting - 12 min read
Trade outcome webhook: grade MT5 trades on position.closed
Detect a stop loss hit, a target hit or a manual close the moment it happens with the position.closed webhook, and grade every signal without polling deals.
WebhooksTrading SignalsMT5 APINode.js - 9 min read
Idempotency keys stop a trading API filling twice
Why a trading API without idempotency keys will eventually fill an order twice, what a good key is, how replay works, and the retry policy that follows.
EngineeringMT5 APIOrder ExecutionReliability - 11 min read
Position size calculator API: lots from the symbol spec
Build a position size calculator on the MT5 API: turn cash at risk into a broker-valid lot size from tick_value, tick_size and volume_step, with real examples.
Position SizingRisk ManagementMT5 APITrading - 12 min read
Place an MT5 order over a REST API: the safe sequence
Place MT5 orders through a REST API without double fills: read the symbol spec, size to volume_step, re-quote, send with an idempotency key, handle 422 and 504.
MT5 APITradingTutorialOrder Execution - 8 min read
Give an AI agent access to your MT5 account safely
Connect Claude, ChatGPT or Cursor to a MetaTrader 5 account without handing over the keys: investor password, a read-only API key with an expiry, and llms.txt.
AI AgentsMetaTrader 5SecurityAPI Keys - 7 min read
Running MetaTrader 5 in Docker with Wine: what it took
How we run MetaTrader 5 headless in Docker with Wine, one account per container: the stack, the parts that broke, and whether you should build it yourself.
EngineeringMetaTrader 5DockerInfrastructure - 8 min read
Lot size calculator formula: pip value and sizing in MT5
The lot size calculator formula explained: pip value for USD pairs, crosses and gold, risk-based sizing with real numbers, and rounding to the broker's step.
Position SizingMetaTrader 5Risk ManagementCopy Trading - 8 min read
Profit factor, win rate, expectancy: what the numbers mean
Get the profit factor calculation, expectancy formula and win rate right, with a worked 10-trade example, sample-size limits, and what a real edge looks like.
Trading MetricsAnalyticsMetaTrader 5MT5 API - 8 min read
API key scopes: least privilege for trading accounts
Which API key scope to hand to dashboards, analysts, AI agents and CI, what a leaked read-only key can actually do, and a five-minute key audit routine.
SecurityAPI KeysMT5 APIBest Practices