Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Expert Advisor | Triangular Arbitrage

MetaTrader Experts, Indicators, Scripts and Libraries

This Expert Advisor (EA) is designed to perform triangular arbitrage between three currency pairs: EURUSD, USDJPY and EURJPY. The main objective is to exploit price discrepancies between these pairs, identifying arbitrage opportunities and opening positions to capitalise on them.

Description of functionalities:

  1. Identifying opportunities: The EA calculates the implied price of EURJPY by multiplying the Ask prices of EURUSD and USDJPY. This value is then compared to the EURJPY direct price. If the relative difference exceeds a defined threshold, an arbitrage opportunity is recognised.

  2. Opening of positions: When an opportunity is identified:

    • If the implied price is higher than the direct price, the EA executes a set of trades including buying EURJPY and selling EURUSD and USDJPY.

    • If the implied price is lower, the EA executes the reverse trade.

  3. Position tracking: The EA tracks open positions using a specific Magic Number. This helps to distinguish trades executed by the EA from others.

  4. Closing positions: When the cumulative profit of open positions exceeds the defined target, all positions associated with the EA are closed.

  5. Error handling: The EA includes error checks to ensure that any problems when opening or closing positions are reported.

In summary, this EA automates the triangular arbitrage process with a systematic approach, optimising returns based on price discrepancies.


57272