The Expert Advisor implements the "triangular arbitrage" strategy, which is successfully used by hedge funds.
"Triangular" arbitrage refers to a class of market-neutral strategies, in which the profit or loss of open positions does not depend on the direction of the market movement as a whole, but om the relative change of asset prices.
The EA tries to profit prom price divergencies between pairs and their cross courses.
The advantages of the strategy
- no risk that market reverses against your position;
- no risk of 'stops' taking by a broker or market maker;
- the strategy is neutral to news swings and gaps.
Risks of the Strategy
- Arbitrage uses hedging, the cost of which may exceed the profit of the strategy;
- Arbitrage positions may long stay in minus;
- Delays in trade execution can lead to losses.
Arbitration strategies are difficult to implement in practice. That is why, they are widely used by hedge funds.
Principles of the strategy
In the interbank market, a cross-rate (for example of EURGBP or EURJPY) may deviate from the ratio (or product) of the rates of two currencies to the US dollar (for example, the EURUSD / GBPUSD ratio or the product of EURUSD x USDJPY /Hereinafter, such a ratio (product) will be called a synthetic cross-rate/).
The cross-rate can deviate from the synthetic cross, because the former depends on the demand and supply of the two currencies relative to each other, and the latter one depends on the demand and supply of these currencies to USD.
Such deviations create the possibility of arbitrage, which is called "triangular", because the arbitrage opportunity is implemented by buying and selling currencies in a triangle (buy EUR sell USD, buy USD sell GBP, buy GBP sell EUR - a triangle is formed).
Although market makers try to eliminate any deviations of rates, in times of strong market movements the market maker might not have the time to "level" the rates. As a result such "triangular" arbitrage opportunities arise more or less regularly (confirmed by numerous empirical studies).
The TriArb Trader EA
- Uses a high-frequency trading algorithm.
- Is Optimized for market execution (but can work in other modes).
- Resistant to execution delays of up to 200 ms.
- Automatically adjusts the "triangle" in case one of positions is not opened or closed by accident.
- Can be configured to trade any combinations of currencies both in direct and reverse quotes.
- Able to "pick up" a position previously opened on a different platform.
- Allows for presence of other EA and manual trading.
- Can adjust Take Profit depending on deviation and slippage when opening a position.
Description of the EA parameters and recommendations on configuration
- Cross pair symbol - symbol of the cross pair. For example, EURJPY or EURGBP.
- First cross pair symbol - the first symbol of the cross pair. Both for EURJPY and EURGBP it is EUR (EURUSD).
- Second cross pair symbol - the second symbol of the cross pair. For EURJPY - JPY (USDJPY). For EURGBP - GBP (GBPUSD).
- Second symbol is in direct quotation - true, if the second symbol is given in a direct quote. GBPUSD is in a direct quote => true. false if the second symbol is given in an indirect quote. USDJPY is in an indirect quote => false.
- Expert Advisor ID (Magic Number) - ID of the Expert Advisor, a unique number for each EA on the account.
- Arb. period (ms) - period for checking the arbitrage conditions. The optimal value in the range 300-500 ms.
- Min. deviation (points) - threshold deviation to open positions. The optimal value is in the range of 8-15 points for a five-digit account.
- Take Profit (USD) - target profit (in the deposit currency) of all three positions, at which the EA will close the triangle. The optimum value ~ Min. deviation x Trading volume.
- Trading volume - lot size. The optimal value depends on the broker's liquidity. With low liquidity, the order is executed at a weighted average price.
Expert Advisor monitoring is available in Signals: ActiveTrades Live.
The set of inputs has been simplified.
Reduced and optimized the amount of entries in the experts log.
- Significantly increased the execution speed of trading orders by the use of high-frequency trading (HFT) algorithms.
- Implementation of a more efficient algorithm for checking the triangle integrity allowed to eliminate the pauses between placing trading orders and checks.
Accordingly, the "Pause before integrity check (ms)" parameter has been excluded from the inputs.
- Significant optimization of the code allowed to additionally increase the execution time of trading operations, which allows the EA to cope with a delay of 300 ms.
Parameters of the EA and their recommended values
- Cross pair symbol - enter the symbol of the cross pair (for example, EURJPY)
- First cross pair symbol - enter the first symbol of the cross pair (in case of EUR - EURUSD)
- Second cross pair symbol - enter the second symbol of the cross pair (in case of JPY - USDJPY)
- Second symbol is in direct quotation - set to true, if the second symbol in the direct quote; set to false if in indirect (in the example with EURJPY, the second symbol is in indirect quote, so set to false)
- Expert Advisor ID (Magic Number) - any integer value less than 2,147,483,647, unique for each EA on the account.
- Max deviation (slipage) - as it is important to ensure the trades are opened, select a sufficiently large value for this parameter (100-200).
- Arb. period (ms) - period for checking the arbitrage conditions (the EA works optimally when the checking period is set to 100-500 ms).
- Max. number of trade retries - the maximum number of attempts to place a trade order (3-4 are enough, but setting 30-40 is more reliable).
- Minimum deviation for in-trade (points) - the minimum deviation of the triangle prices for opening position (works well with 5-15 points for five-digit account, however, when increasing the Take Profit parameter, it is better to increase the value to 20-40. Decreasing the parameter to 2 while reducing the Take Profit defines the mode of risky scalping).
- Minimum deviation for out-trade (points)- the minimum deviation of the triangle prices for closing position once the total loss of triangle position exceeds the value of the Max. Loss parameter (it is better to set it 1.5-2 times less than the Minimum Deviation for in-trade).
- Take Profit (USD) - the total profit (in the deposit currency) of three positions in the triangle, at which the EA generates a signal to close the position (optimally exits the position when set to 2-4 at lot size of 0.1; for other lot sizes, change the parameter value proportionally, i.e. the optimum Take Profit for 1 lot is 20-40).
- Max. Loss (USD) - maximum total loss (in the deposit currency) of all three positions, at which the EA uses exit if the inverse deviation of the triangle prices is greater than the value of the 'Minimum deviation for out-trade' parameter (it is better to leave the value 4-5 times greater than 'Take Profit', but not greater than USD200, otherwise it will close with significant losses during strong impulses).
- Trading volume - all recommended values were derived from 0.1 lot (for other lots, the Take Profit and Stop Loss parameters should be changed proportionally).
Before running on a real account, make sure you understand the operation mechanism as well as the purpose of the EA parameters!!!
- Added check of zero ticks. This check solves the problem of missing ticks that occurred in tester (ONLY in tester) when testing on real ticks.
- Added the ability to re-send a trade request in case of failure. The number of attempts is defined in "Max. number of trade retries". This option increases the reliability of trading operations.
- Added a pause between the time when a message about the acceptance of a trade order for execution is received from the trade server and start of check of the "triangle" integrity. The duration of the pause is configured in "Pause before integrity check (msc)". This pause is necessary if reports about position opening are delivered from the server with a delay. If the EA started integrity check before the report about position opening or closure is received, it saw the missing/excessive position and immediately tried to solve the problem, which led to repeated opening/closing of the position.
- Position closing logic changed. IN a normal situation positions are closed upon reaching the total profit of all three positions of the triangle, which should exceed "Take-Profit (USD)" (set in deposit currency).
However, if the position does not move to profit, and the loss of a position (module) exceeds "Max. Loss (USD)" (also in deposit currency), the position is closed using the parameter "Minimum deviation for out-trade (points)". I.e. if loss is too large, the position will be closed in case of deviation of "triangle" prices.
Thus, the minimum price deviation (formerly arbitration threshold) is now set separately for position opening and closing. "Minimum deviation for IN-trade (points)" sets the minimum threshold for position opening. "Minimum deviation for OUT-trade (points)" sets the minimum threshold for position closing.
- Significantly improved the reliability of the EA on hedging accounts.
ATTENTION! The EA available on the Market has non-optimal parameters.
Recommended EA parameters are below:
Parameter | Recommended value
- First major pair (vs USD) | EURUSD
- Second major pair (vs USD) | GBPUSD
- Cross pair (as First major vs Second major) | EURGBP
Both majors are in direct quotation | true
- Expert Advisor ID (Magic Number) | 666
- Max deviation (slipage) | 30
- Arb. period (msec) | 500
- Pause before integrity check (msc) | 10
- Max. number of trade retries | 10
- Minimum deviation for in-trade (points) | 10 (5-digit)
- Minimum deviation for out-trade (points) | 20 (5-digit)
- Take Profit (points) | 20
- Msx. Loss (points) | 30
- Trading volume | 0.1
Specific values of optimal parameters depend on the trading conditions of your broker.