Skip to content
All library documents

Finding Forex Triangular Arbitrage Cycles with Graph Algorithms

Article MQL5 articles

Summary

The article models currency pairs as directed graph edges and currencies as vertices, assigning exchange-rate weights that account for bid or ask prices. A closed path may present triangular arbitrage when its combined conversion rate exceeds transaction costs. It describes building this graph from broker quotes, filtering pairs by spread, and searching for cycles with Floyd–Warshall and depth-first search. A balancing component is intended to size trades so each currency’s net exposure is zero, while execution and risk modules address partial fills, averaging, and emergency exits.

The article reports demo testing with graphs exceeding 25 currencies and 500 edges, and gives claimed search-speed and opportunity-frequency observations. These are implementation-specific results, not evidence of live profitability. Opportunities are described as rare and short-lived, and real execution faces spreads, slippage, latency, broker constraints, and the risk that a multi-leg cycle does not fill atomically. Position averaging also adds risk to a strategy presented as arbitrage.

Key ideas

  • Currencies can be represented as graph vertices, with directed exchange operations represented as weighted edges.
  • A closed exchange cycle is potentially profitable only after spreads and transaction costs are included.
  • The proposed EA combines Floyd–Warshall path analysis with depth-first cycle enumeration.
  • Lot sizes must be balanced across legs to control net currency exposure.
  • Demo implementation results do not establish live profitability, especially when fills can be partial or delayed.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.