MT4 vs MT5
The trading API is the same on both platforms, with a few differences worth knowing.
The Trading API has the same endpoints on MetaTrader 4 and MetaTrader 5 — the same 19 endpoints, the same paths, the same parameters. You do not need to write against one or the other: an MT4 account and an MT5 account answer the same calls. Where the platforms themselves differ, the answers differ too; this page lists where.
Commissions
GET /SymbolInfo reports commission differently, because the two platforms expose
different information.
MetaTrader 5 — the broker's actual rules
MT5 exposes commission configuration server-side, so the response carries it
structured, under commissions:
{
"symbol": "EURUSD",
"commissions": [
{
"chargeMode": "instant",
"entryMode": "both",
"directionMode": "both",
"profitMode": "all",
"rangeMode": "lots",
"currency": "USD",
"tiers": [
{
"mode": "money",
"volumeType": "by_volume",
"value": 3.5,
"rangeFrom": 0,
"rangeTo": 0,
"minValue": 0,
"maxValue": 0,
"currency": "USD"
}
]
}
]
}Each rule says when it is charged (chargeMode), whether it applies on entry,
exit or both (entryMode), to buys, sells or both (directionMode), and to all
deals or only profitable or losing ones (profitMode). The tiers hold the
amounts and the volume or turnover ranges they apply to.
These are the broker's configured rules, so they are authoritative.
MetaTrader 4 — an estimate from your own history
MT4 has no equivalent API. API v2 therefore derives a figure from the account's most recent closed orders:
{
"symbol": "EURUSD",
"commissionPerLot": 7.0,
"commissionSamples": 12
}| Field | Meaning |
|---|---|
commissionPerLot | Estimated commission for 1.0 lot |
commissionSamples | How many closed orders the estimate came from — 0 means no estimate was possible |
Treat the MT4 figure as an estimate
It is calculated from what your account was actually charged, not from the
broker's configuration. With commissionSamples: 0 there is no history to
derive it from and commissionPerLot carries no information. A new account
reports 0 until it has closed trades, and a broker that changes its
commission is not reflected until new trades land.
Writing for both
If your code supports both platforms, read whichever field is present:
function commissionPerLot(symbolInfo) {
// MT5: the broker's rules. Take the first money-per-volume tier.
if (Array.isArray(symbolInfo.commissions)) {
for (const rule of symbolInfo.commissions) {
for (const tier of rule.tiers ?? []) {
if (tier.mode === 'money' && tier.volumeType === 'by_volume') {
return { value: tier.value, source: 'broker' }
}
}
}
return { value: null, source: 'broker' }
}
// MT4: an estimate, and only if there was history to estimate from.
if (symbolInfo.commissionSamples > 0) {
return { value: symbolInfo.commissionPerLot, source: 'estimate' }
}
return { value: null, source: 'none' }
}Partial closes on MT4
On MT5 a position keeps its ticket when you close part of it. On MT4, closing part of an order moves the rest to a new ticket, and the API tells you which:
- the
/OrderClosereply carries the new ticket inremainderTicket; - on the
tradestopic, theOutframe carriesremainderTicketand the remainder'sInframe carriesremainderOf, the ticket it came from.
positionVolume follows the chain, so it still says how much of the original
position is open. On MT5 both fields are always 0.
Stop-loss and take-profit in the history
/OrderHistory and /PositionHistory rows carry sl and tp; 0 means none
was set.
- MT5 records them per deal: an
Inrow has the levels sent with the opening order, anOutrow the position's levels when it closed./PositionHistoryshows the levels at close. - MT4 keeps one pair per order: its levels when it closed, in both endpoints.
For the risk a trade started with — R multiples, for example — take sl from
the In row on MT5, matched to the position by position. A stop moved later,
trailed or set to break-even, shows only its last level. A stop added after the
order was placed is 0 on the In row, and MT4 never keeps the original stop.
To have it in every case, record it while the position is open: the trade and
modify frames on the trades topic
carry the stops at every change.
Check the version first
sl and tp on history rows come with version 0.18.3 on MT5 and 0.16.2
on MT4 — GET /status reports it as bridge.version. Older versions leave
both fields out. Connections move to the new version when they restart.
Everything else that differs
| MT5 | MT4 | |
|---|---|---|
Stop-limit orders (BuyStopLimit, SellStopLimit) | Yes | No — 400 MRPC_UNSUPPORTED |
/OrderHistory | One row per deal | One row per closed order |
trade frames | deal is the deal ticket | deal is 0; order and position are the order ticket — deduplicate on order plus entry |
/SymbolInfo orderModes, expirationModes, fillingModes | The broker's settings for the symbol | A fixed set: no stop-limit, expiry gtc or specified, no filling modes |
/PendingOrders | Partly filled orders show volume below volumeInitial | No partial fills and no stop-limit: volume = volumeInitial, stopLimitPrice is 0 |
Brokers also set a minimum distance for a pending order's expiry — often a few minutes on MT5, and more on MT4, where ten minutes or longer is common. An expiry closer than that is rejected by the broker.
Everything else — quotes, bars, symbols, positions, placing, modifying and closing orders, and the rest of the WebSocket — behaves the same on both.