MT4 Indicators‎ > ‎

Pairs Trading MT4 Indicator

If you've ever wondered about pairs trading or statistical arbitrage, the Pairs with Beta MT4 indicator will help identify opportunities in the forex market.  Pairs trading is a form of statistical arbitrage where profit is made in the currency market from taking a market neutral position and capturing the spread between two or more currency pairs. In the forex market the concept is related to, but different than triangular arbitrage or tri arb, which looks to combine three related currency pairs to capture market inefficiency.

To help visualize the spread (sometimes known as the delta) between two pairs, I created a simple pairs trading indicator for Metatrader 4 (MT4) named Pairs with Beta. It allows customization of the beta or constant weight to be input by the trader for each pair, and shows the resulting two pair spread. Generally speaking, you will want to base the beta on the relative volatility of the pairs. For instance, if pair 1 is two times more volatile than pair one, you might use a Beta2 of 2.0 to offset the relative higher volatility of the first symbol.

For example if the desired pair is EURUSD and GBPUSD and currently the beta on GBPUSD is 1.4 compared to EURUSD, just use the default inputs:

extern double Beta1 = 1.0;  // Applies to the symbol in the chart
extern string Symbol2 = "GBPUSD";
extern double Beta2 = 1.4; // applies to GBPUSD
In this case Beta1 relates to the chart that is used, and Beta2 relates to the Symbol2 (GBPUSD) input by the trader.

The formula for the Pairs with Beta indicator then becomes: EURUSD * 1.0 - GBPUSD * 1.4

This result has been reproduced for MT4 below in DodgerBlue for the Pairs with Beta MT4 indicator:
Pairs Trading MT4 indicator with Beta EURUSD * 1.0 - GBPUSD * 1.4

Note for Pairs with Beta.mq4: if you wish to use this indicator with mismatched symbol denominators, such as with EURUSD and USDCHF, and if USDCHF is Symbol2, make sure Beta2 is a negative number! The formula is meant to handle two pairs, and the second pair is subtracted by default. Making Beta2 negative effectively makes the formula EURUSD + USDCHF.

Note for Pairs with Beta4.mq4: This version handles up to 4 individual pairs making a single spread from the formula symbol1 + symbol2 + symbol3 + symbol4. If you wish to subtract a symbol, make its beta value negative, such as EURUSD - GBPUSD + AUDUSD - NZDUSD (Beta2 = -1.0, Beta4 = -1.0) etc. Experiment with different weights based on the relative volatility of the symbols being considered and you might see some interesting results! The goal should be to increase the stationarity of the underlying spread. Stationary time series have a constant mean, variance and autocorrelation. So a series that is more bounded and less trendy tends to be easier to trade using a mean reversion strategy.

Further note for JPY denominated pairs: To mix/match JPY pairs with USD based pairs such as EURUSD and EURJPY, with a EURJPY beta of 1.4, make sure Beta2 is 0.014 (divide by 100) so both prices will be on the same scale.

There is a forum discussion on the topic of Statistical Arbitrage / Pairs Trading Strategy that is a good read for traders interested in those topics..

You may also post comments and questions on the blog post Pairs Trading MT4 Indicator if you want a reply from me.

The MT4 MQL4 code is attached below for free download and use. Download free Pairs with Beta.mq4 or Pairs with Beta4.mq4 MT4 indicator now! You may post these MT4 indicators to other sites, but if you do, you must post a link to this page directly and you may not sell the indicators or the source code. You are otherwise free to copy, use and distribute these MT4 indicators for non-commercial use. Place the Pairs with Beta.mq4 or Pairs with Beta4.mq4 file in your ..\experts\indicators\ folder. Please see the MQL4 code for additional licensing information.
For updates Follow patrickmwhite on Twitter
Č
ċ
Pairs with Beta 4.ex4
(3k)
Patrick White,
Nov 30, 2012, 10:20 PM
ċ
Pairs with Beta 4.mq4
(3k)
Patrick White,
Nov 30, 2012, 10:19 PM
ċ
Pairs with Beta.ex4
(2k)
Patrick White,
Jun 7, 2012, 10:52 AM
ċ
Pairs with Beta.mq4
(3k)
Patrick White,
Jun 7, 2012, 10:52 AM
Comments