MT5 Broker and Datafeed
Mt5Broker and Mt5DataFeed are live-only integrations that connect AQE to a running MetaTrader 5 terminal through the local AQE MT5 bridge.
They are designed for:
- live account snapshots
- latest quote and bar updates
- order submission and cancellation
- position close requests
- trade event delivery back into AQE
The MT5 bridge requires the AQE bridge service to run locally and the MT5 Expert Advisor to be attached to a terminal chart with matching session and token settings.
Setting up the MT5 integration
Section titled “Setting up the MT5 integration”The MT5 integration has two sides:
- AQE side:
Mt5BrokerandMt5DataFeedtalk to the local MT5 bridge using the configured bridge token and bind address. - MT5 terminal side: the AQE Expert Advisor runs inside MetaTrader 5 and polls the local AQE bridge for market-data and broker RPC requests.
Use this setup flow:
- Install or update the AQE MT5 Expert Advisor from the AQE repository.
- Start MetaTrader 5 and sign in to the account you want AQE to use.
- Attach the AQE Expert Advisor to a chart for a symbol your broker exposes.
- Set the same
AQE_MT5_BRIDGE_TOKENin the AQE runtime environment and in the Expert Advisor. - Keep the bridge bind address aligned between AQE and the Expert Advisor. The default local address is
127.0.0.1:18080. - Start the AQE runtime and confirm the Expert Advisor is polling the bridge.
For the Expert Advisor files, installation notes, and bridge README, see the AQE MT5 integration directory on GitHub: algoquantstudio/aq-engine integrations/mt5.
When using MT5 for live execution, verify fills, stops, account state, and open positions in the MT5 terminal. AQE receives broker updates from the bridge, but the MT5 account remains the source of truth for live execution.
MT5 fee data
Section titled “MT5 fee data”For MT5 symbol metadata, swaps come from the terminal symbol information. The AQE Expert Advisor maps SYMBOL_SWAP_MODE, SYMBOL_SWAP_LONG, and SYMBOL_SWAP_SHORT into Asset.fees.swap.long and Asset.fees.swap.short.
MT5 currency swap modes map to AssetFee::PerContractFee. MT5 interest/current/open percentage swap modes map to AssetFee::PercentagePerContractFee as a daily decimal rate, so 0.0001 means 0.01% per day. MT5 reopen-point swap modes map to AssetFee::Points.
MT5 commissions are different. Symbol metadata is not authoritative for commission because broker commission is only reliable after a deal is executed. AQE therefore treats commission values from executed MT5 deals as authoritative, using DEAL_COMMISSION plus DEAL_FEE from the trade event or close-position response. If a broker reports zero commission, AQE records zero.
Backtests do not use MT5 deal commission discovery. Configure the PaperBroker asset fee model explicitly for historical runs.
Related source
Section titled “Related source”aq-engine/src/core/broker/mt5_broker.rsaq-engine/integrations/mt5
We use essential cookies and storage for sign-in, account security, colour theme preferences, this notice, and required PostHog internal usage, session quality, and reliability metrics. We do not use advertising cookies.
