View as Markdown

MT4 and MT5

One API for both platforms, and the few things MT4 can't do.

Pick the platform when you create an account ("platform": "mt4" or "mt5"). After that, every endpoint, field and stream frame is the same.

What’s different

MT4 is an older platform and lacks a few features. Calls for them return not_supported_on_mt4:

CapabilityMT5MT4
Market depth (current-book, marketDepth stream)Yesnot_supported_on_mt4
Historical ticks (REST and the ticks stream)Yesnot_supported_on_mt4
Stop-limit ordersYesnot_supported_on_mt4
DAY and SPECIFIED_DAY expiry on pending ordersYesnot_supported_on_mt4. Use a set expiry time, or none
Netting accountsYesNo. MT4 accounts are hedging only
Terminal order check on trade/checkYesNo. We still check the request, and orderCheck is false
Close-byYes, on hedging accountsDepends on the broker
Timeframes21, from 1m to 1mn1m 5m 15m 30m 1h 4h 1d 1w 1mn
HistoryDeals, orders and positionsClosed orders, exposed as deals and history orders

Ask the account up front instead of catching errors:

curl -s https://api.tickwire.io/users/current/accounts/acc_7Qx/capabilities -H "auth-token: $TW_KEY"

The flags sit under features. This is an MT4 account, shortened:

{
  "platform": "mt4",
  "marginMode": "ACCOUNT_MARGIN_MODE_RETAIL_HEDGING",
  "features": {
    "marketDepth": false,
    "historicalTicks": false,
    "stopLimitOrders": false,
    "closeBy": "broker_dependent",
    "nettingAccounts": false,
    "orderCheck": false,
    "pendingOrders": true,
    "partialClose": true
  },
  "timeframes": ["1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w", "1mn"],
  "limits": { "historicalTicksMaxLimit": 0 }
}

closeBy is "broker_dependent" on MT4, because some MT4 brokers forbid it. On MT5 it is true on hedging accounts, false on netting accounts, and "unknown" until the account has been read.

How a refusal comes back

The error code is always not_supported_on_mt4. The HTTP status depends on the route:

RouteAnswer
/users/current/… market data (current-book, tick history)400 with the error body
/users/current/…/trade200 with numericCode: -4, outcome: "rejected" and error: "not_supported_on_mt4". Nothing was sent
/mt4/{id}/…400 with the error body
Account streamAn error frame for that subscription. The rest of the stream carries on

A market depth call on an MT4 account answers:

{
  "id": 1,
  "error": "not_supported_on_mt4",
  "message": "market depth is not available on MT4",
  "tickwireError": "not_supported_on_mt4",
  "feature": "market depth"
}

Hedging and netting (MT5)

MT5 accounts are either hedging (many positions per symbol) or netting (one). marginMode in account information tells you which. On hedging accounts, closes must name a positionId; on netting accounts, positions are identified by their MT5 position identifier, which stays stable while the position is scaled in and out.