Skip to content
Returning.AIDocs

MetaTrader

MetaTrader can be a trading-data source for Returning.AI, but it is not the same thing as widget authentication. Use it to retrieve deals, positions, groups, symbols, and account facts after the trader identity model is agreed.

MT5 approach

The MT5 path is usually a read connector that pulls data by login and time window. Before committing to scope, verify authentication, command names, host rules, and whether the broker allows group-wide queries or only account-by-account reads.

DataTypical useQuestion to confirm
User / accountMap customer IDs to MT5 logins and groupsCan we query by login, group, or both?
Deals / historyLots, symbols, close time, volume, PnL, commissionsWhich timestamp defines the reward window?
PositionsOpen exposure, active trader state, campaign eligibilityDo open positions count, or only closed deals?
Symbols / groupsAsset-class mapping, excluded symbols, B-book/A-book segmentationWhich groups and symbols are in scope for loyalty?

MT4 approach

MT4 does not have the same modern Web API assumptions as MT5. A real MT4 integration typically needs one of these broker-side options:

  • Manager API access through a Windows service or broker-hosted bridge.
  • A scheduled export from the broker back office or reporting database.
  • A broker API that already normalizes MT4 logins and trading history.
  • CSV or SQS delivery when direct MT4 access is operationally blocked.

Polling model

Avoid one giant server-wide pull unless the broker has explicitly proven that command and volume. A safer design is cursor-based:

  1. 1. Hot accounts. Poll recently active logins more frequently.
  2. 2. Warm accounts. Poll known but inactive logins less frequently.
  3. 3. Backfills. Run explicit historical jobs with bounded windows and replayable outputs.
  4. 4. Queue output. Push normalized activity into SQS or an internal ingestion endpoint with idempotency keys.

Broker questions

  • Which platforms are in scope: MT4, MT5, or both?
  • What is the stable broker customer ID, and how does it map to trading account logins?
  • Can the broker provide read-only server access, a reporting API, or scheduled exports?
  • Which account groups, books, symbols, and jurisdictions should be included or excluded?
  • Do bonuses, credit, rebates, and real deposits have separate ledger fields?
  • Should reward calculations use closed deals only, or also open positions?

Do not assume

  • Do not assume investor passwords are enough for production data sync.
  • Do not assume Dynamic Works, FXBO, or a client portal is the trading source of truth.
  • Do not assume every broker can expose server-wide history safely.
  • Do not assume MT4 and MT5 commands, casing, sessions, and fields are interchangeable.