Skip to content
NewThe live risk and unusual-trading desk for MT5 brokers
GarnetSync

Why MT5 deposits must land exactly once, and how to prove it

MetaTrader 5 has no idempotency key for balance operations. Here is how a back office avoids double credits when the network drops at the worst moment.

GarnetSync Editorial

Product & Engineering, , 3 min read

A deposit on MetaTrader 5 is a balance operation: the back office asks the server to credit an account, and the server answers with a deal ticket. Most of the time this takes milliseconds. The interesting cases are the rare ones, and they are where money is lost.

The lost answer

Imagine the request reaches the server, the account is credited, and the connection drops before the answer comes back. The back office doesn't know whether the deposit happened. If it simply tries again, the client is credited twice. MT5's API has no idempotency key that would let the server recognise the second request as a repeat.

Record first, credit once

The safe pattern has three parts:

  1. Record the operation before sending it. The back office writes the operation, with a short unique tag, to its own database first. Once written, it is frozen.
  2. Send it. The tag travels in the deal's comment. Deal comments on MT5 are capped at 31 characters, so the tag must be short and neutral.
  3. Settle from the server's deals. If the answer is lost, the back office waits at least a minute, then searches the server's deals for its tag. Found: the operation is settled with that ticket. Proven absent: only then is it sent again, and never without limit (we stop at three sends). Still unsettled after a day: a person decides, with what to look for in MT5.

The rule that matters is the last one: a lost answer is never "fixed" by sending the operation again blindly. A second send waits until the server's own deals prove the first one never landed.

Proving it every day

Even a perfect sending path deserves a check. Re-read each ended server day and match every deal to the ledger by ticket, not by amount. Two deposits of the same amount on the same day are common; two deals with the same ticket are impossible.

CheckMatched byCatches
Live settlementTag in the commentLost answers
Daily reconciliationDeal ticketAnything done outside the back office
Bridge monitoringConnection stateOutages, emailed to managers after 5 minutes

Server time

MT5 reports times in the server's own time zone, and many servers follow a daylight-saving schedule. A day that is "settled" must be the server's day, re-read after it has ended, or totals will drift by an hour twice a year.

What to ask your vendor

Ask what happens when the answer to a deposit is lost. If the answer is a retry without first searching the server's deals, keep looking.

  • MetaTrader 5
  • Web API
  • Back office
All articles