MetaTrader 4 (MT4) and MetaTrader 5 (MT5) are the dominant trading platforms in the retail Forex industry. Your IB program must integrate tightly with your MetaTrader instance to track client trading activity, calculate commissions accurately, and provide real-time reporting.
What Integration Means
IB-MetaTrader integration means your affiliate management platform reads trading data from your MT4/MT5 server and uses it to calculate IB commissions. This requires:
Trade data sync: Every closed trade (and optionally, open trades) is read from the MT server and processed for commission calculation.
Client-IB mapping: Each trading account is linked to the IB who referred the client. This mapping must be maintained in your affiliate platform.
Commission calculation: Based on the trade data and the IB deal structure, commissions are calculated per trade and aggregated.
Real-time or near-real-time processing: IBs expect to see their commissions update throughout the trading day, not just at end-of-day.
Integration Methods
Method
Speed
Complexity
Reliability
Manager API
Real-time
High
High
Server plugin
Real-time
Very high
Very high
Database read
Near-real-time
Medium
Medium
Report import
Delayed
Low
Low
The Manager API is the most common approach. Your affiliate platform connects to the MT server using the Manager API protocol, authenticates with manager credentials, and reads trade data programmatically. This provides real-time access without modifying the MT server.
MT5 has a different API architecture than MT4. If your brokerage runs both platforms (which is common), your affiliate system needs to support both integration protocols. Ensure your affiliate platform vendor confirms dual-platform compatibility.
Commission Calculation Logic
Once trade data is synced, commission calculation follows these steps:
Identify the trading account and look up the associated IB.
Determine the IB deal structure (lot-based, spread-based, or custom).
Read the trade details: symbol, volume (lots), spread at execution, and any commissions charged.
Calculate the IB commission for that trade based on the deal structure.
If the IB is part of a multi-level hierarchy, calculate override commissions for parent IBs.
Aggregate commissions and update the IB dashboard in real time.
Common Integration Challenges
Account grouping: A single trader may have multiple MT accounts. Your system needs to attribute all accounts to the correct IB.
Symbol mapping: MT4/MT5 symbol names may differ from standard naming. Your commission rules need to map correctly (e.g., EURUSD vs EURUSDm vs EURUSD.raw).
Partial lots: Ensure your system handles mini and micro lots correctly in commission calculations.