Creating and testing arbitrage strategies

 

As you know, in arbitrage it is very important to find highly correlated pairs or portfolios of instruments. It often happens that correlation "goes away" at different times, and then it is restored. So an arbitrator has to constantly search for correlated pairs and portfolios, download and align instrument quotations in Excel somewhere, calculate parameters, find entry/exit points, calculate profit. And all this is mostly done manually, by "digging through" a huge number of files and wasting time.

To ease the work of arbitrageurs, we developed the Expert Advisor Tester with a full-blown windows-based user interface. The interface is written on the basis of the standard MQL5 library and allows easy creation of various arbitrage strategies, setting parameters and testing.

ArCo is an Arbitrage Expert Advisor. Version 1.1 beta

Expert Advisor Arbitrage Strategies

In the Expert Advisor, you can create almost all types of arbitrage:

-pair (instrument-tool);

-Index arbitrage (index-synthetic), including hedging;

-basket-basket.

Device of the adviser

Expert Advisor can create arbitrage strategies, save, rename and delete them. The strategies are stored as settings files in the folder "ArCo1.1/Strategies" of the common folder"Files" of MT5.

An alignment symbol is selected in each strategy, it is necessary to align by time the quotes of all symbols included in the strategy.

Each strategy has its own parameters: symbol baskets, volume definition, entry/exit conditions.

The testing is done on the last loaded strategy and on the alignment symbol. Every strategy step is logged in the tester log. The amount of commission can also be viewed there.

There are two indicators in the Expert Advisor:

- "Baskets"- for visual viewing of the sum of quotes of the symbols of the baskets;

-Spread" - calculation of spread and correlation of baskets.


Structure of the strategy

The strategy has two symbol baskets, one for the left hand basket and one for the right hand basket. The baskets are identical in structure, except for the entry and exit rule: the left hand basket always starts.

Symbols from the Market Watch can be added, removed and replaced in the baskets. The volume (number of contracts-lots), maximum spread, etc. are set for each symbol.

Entry/exit, profit and loss conditions can be set by selecting appropriate menu items.

Two levels of averaging can be defined in the strategy.

Trading Principle

The operation is based on spread buy/sell when the specified correlation levels are reached.

Spread buying is buying the left hand basket and selling the right hand basket. Spread closing is selling the left hand basket and buying the right hand basket.

Selling the spread is selling the left basket and buying the right basket. Closing the selling spread is buying the left-selling the right basket.

Position averaging is adding volumes as a percentage to an existing position.

Buying and selling of instruments is "on the market".

Quick start

Unzip the file and put the "ArCo1.1" advisor folder into the"Experts" folder, and the "ArCo1.1 Indicators" folder into the"Indicators" folder. The advisor has the help file ArCo1.1.chm

Strategy building

Place the Expert Advisor on the current chart. 2.

Click "ArCo1.1 Settings" button. The main window of the user interface will appear.


At every stage of making the strategy, you can test it by selecting the menu item "Strategy - Test" and get a hint.4.

4. From the "Strategy" menu, select "Create".

Enter a free strategy name in the "Strategy File Name" field. Click "OK". The file name appears in the header of the main form.

Click on the "Add" button on the left side of the cart. Select a symbol in the "Select Symbol" window and click on "OK". 8.

7. highlight the symbol in the basket and click on the "Configure" button.


8. in the "Symbol setting" window enter the volume (in contracts or lots), maximum spread (in points). If the real spread is higher than the maximum spread, the symbol will not be traded. The lists "Bin buy" and "Bin sell" and "Do not include in charts" are needed for a specific type of strategy, such as hedging, and in most cases they are left by default. Set the amount of commission per contract, if required. Click on OK.

9 Repeat points 6, 7, 8 for the right hand basket.

10 Select the alignment symbol in the main window. This is used to time synchronize all the quotes for the symbols of the strategy. After this 2 indicators of the Expert Advisor should appear in the current window of MT5. If they do not appear immediately (because of the quotes download), it is necessary to click on different timeframes of the chart period, as if "pump" the quotes. On weak computers you can reduce the number of displayed bars from the menu item "Settings - Indicators".

11. in the main window choose the item "Trading settings - Entry conditions". Enter the correlation levels for selling and buying spreads in the window. Click the "OK" button.

Select "Trading Parameters - Exit Conditions" in the main window. In the window enter the correlation levels for closing sell and closing buy spreads. If necessary enter values for profit and loss. Click "OK".


13. If position averaging is required, select "Trading Parameters - Position Averaging" and enter appropriate values.

Strategy backtesting

The testing is done on the last strategy opened and on the alignment symbol.

  1. Open the MT5 Tester.
  2. Select the ArCo1.1 Expert Advisor.
  3. Choose an alignment symbol.
  4. Select time frame.
  5. Test it.

Buy and sell symbols "by market". All trading of the Expert Advisor is logged in the Strategy Tester journal. There you can view the total commission.

Conclusion

The Expert Advisor was compiled on a 32-bit machine.

The Expert Advisor was tested in MT5 at Otkritie broker on a real account.

Sometimes it shows very interesting results. For example, on the pair RTS - Sber futures for October 2013.


The author will be happy to discuss all requests, remarks and suggestions for improvement of his Expert Advisor.

Files:
Arko1_1.zip  722 kb
 
Post your programs with descriptions either in the Market or in the Code Base. The forum will either delete the post or it will get lost in a couple of days.
 
paladin800:
The forum will either delete the post or post it through a couple of sorts of junk. The forum will either delete the post or it will get lost in a couple of days.

Yeah, and post all kinds of rubbish in here...

This is where it belongs. The man wants to discuss a promising trading system. He even posted functionality.

 

Also trading arbitrage on forts. Robot on MT5 on the way.

IRash, how long have you been practicing? What baskets do you use?

 
pronych:

Also trading arbitrage on forts. Robot on MT5 on the way.

IRash, how long have you been practicing? What baskets do you use?

I've been using MT5 only recently, I was attracted by the availability of historical tick quotes.

Some baskets are unbalanced. One instrument slows down, the other already slows down. And basket correlation shows average hospital temperature). A better portfolio of futures pairs is better.

 
IRash:

I have only recently started working in MT5, I was attracted by the availability of historical tick quotes.

The baskets are a bit unbalanced right now. One instrument doesn't make it, the other is already back. A portfolio of pairs is better.

I've done so much work that I'm not comfortable criticising. But the truth is dearer: all these left/right baskets are a dead end. That's not how the spread should be calculated.

 
MetaDriver:

There you go, sober thoughts. So much work done, it's embarrassing to criticise. But the truth is dearer: all these left/right baskets are a dead end. This is not the way to calculate the spread.

Baskets are a universal tool, after all. And work - I simply transferred the functionality of the arbitrator's gentleman's kit from another platform
 
MetaDriver:

But then again, the truth is dearer: all these left/right baskets are a dead-end road.

But it's a classic! - Left and right legs.

>This is not how the spread should be calculated.

Any interesting thoughts?

 
IRash:

Baskets are, after all, a universal tool.

Mmm... I'm not going to argue with that yet. The main question is: why are there two of them?


And the work - I simply transferred the functionality of the arbitrator's gentleman's kit from another platform

... for half an hour? :)
 
IRash:

But it's a classic! - left and right legs.

> That's not how the spread should be calculated.

Any interesting thoughts?

Check your personal email.
 
MetaDriver:
Mmm... I can't argue with that yet. The main question is, why two of them?


... in half an hour?)
In two months.
Reason: