Mastering Trade-Arbitrage with MetaTrader 4: A Comprehensive Guide

Mike 2009.11.27 19:46 32 0 0
Attachments

Theory:

Let’s dive into how Trade-Arbitrage functions, especially with the popular EURUSD pair. Picture this: you have two synthetic pairs, EURUSDx and EURUSDy.

These pairs often move in sync, so when you open two opposite positions, you effectively create a hedged position. Here’s how it works:

Open: Buy EURUSDx and Sell EURUSDy. After some time, close these positions: Sell EURUSDx and Buy EURUSDy.

Profit Calculation: Profit = (BIDx - ASKx) + (BIDy - ASKy) = (BIDx - ASKy) + (BIDy - ASKx)

In the equation above, we know the value from the first bracket (the initial Buy and Sell positions on EURUSDx and EURUSDy).

The value from the second bracket is determined once we close those positions (the Sell and Buy actions).

There are several scenarios that yield a positive profit. Here’s one:

At open: BIDx > ASKy,

At close: BIDy > ASKx.

Practice:

Your Trade-Arbitrage expert advisor leverages this strategy (and you can tweak it for different conditions). In real-time, it scans for instances when BIDx > ASKy across all possible synthetic pairs (think thousands of cases) and opens the relevant positions.

This means that the Trade-Arbitrage expert advisor maintains a multicurrency hedge at all times.

It generates a file called ArbitrageStatistic.txt that sorts arbitrage cases by frequency.


Example of ArbitrageStatistic.txt

If Monitoring is set to TRUE, the advisor logs some arbitrage details into a file called Arbitrage.txt.


Details from Arbitrage.txt

The trading operates with pairs specified in the Trade-Arbitrage.txt file, located at experts\files.


Example of Trade-Arbitrage.txt

Additionally, it records details for further analysis, including deals, reasons, and results:


Results from the Trade-Arbitrage advisor (top), NettoTrading (left), and CheckMyArbitrage (right)

You can check the multicurrency hedge using a cycling script called CheckMyArbitrage.

Input Parameters:

  • Currencies - List of currencies used for the synthetic pair.
  • MinPips - Minimum allowed difference in points (previously referred to as arbitrage) between BIDx and ASKy.
  • SlipPage - Slippage in pips permitted by the broker for Market orders (this can vary by broker).
  • Lock - Allow locks (TRUE) or not (FALSE).
  • Lots - Position volume for opening/closing trades.
  • MaxLot - Maximum lot size allowed by the broker (real).
  • MinLot - Minimum lot size allowed by the broker (real).
  • Monitoring - Log all arbitrage cases to the file (TRUE) or not (FALSE). Logging might take some time, which can be critical for arbitrage.
  • TimeToWrite - Logging time period (in minutes) for the arbitrage statistical data (ArbitrageStatistic.txt).

Expert Performance:

  • Handles trade order errors (like Rejects).
  • Partial executions are supported (Partial Fills), depending on broker policies.
  • Utilizes a feature with the minimum possible lot allowed by the broker (MinLot).
  • If Lock = TRUE, it employs minimal trade orders.
  • It can prohibit locking cases (Lock = FALSE).

Potential Issues:

  • Negative slippages and commissions can erode profits.
  • Long execution times for trade orders can lead to price changes on other symbols.
  • Asynchronous processing of trade orders by brokers may present challenges.
  • Short arbitrage windows can be problematic.

Possible Improvements:

  • Utilizing limit orders.
  • Simultaneous sending of trade orders for various symbols (to emulate asynchronicity) from multiple terminals for one account.
  • Time management to account for broker asynchronicity.
  • Collecting and utilizing more statistical information for other MinPips arbitration conditions, such as BIDx - ASKy > SPREADx + SPREADy.
  • Gathering and applying statistical data on the duration of arbitrage opportunities.
  • Setting priority in the Market-orders queue based on tick volume or extreme local prices.

Key Features:

  • Multicurrency capability, so it’s not suitable for strategy testing but can be executed as a script.
  • Price history is not utilized; the arbitrage theory relies on market inefficiencies (the inefficiency of quotes), making the nature of quotes irrelevant.
  • The advisor operates without incurring losses.

Editor's Note:

This is a mirror translation of the original Russian version.

If you have questions for the author, suggestions, or comments, it’s best to post them there.

If you find this code useful for trading or educational purposes, don’t forget to thank the author!

List
Comments 0