Discussion of article "An Example of Developing a Spread Strategy for Moscow Exchange Futures"

 

New article An Example of Developing a Spread Strategy for Moscow Exchange Futures has been published:

The MetaTrader 5 platform allows developing and testing trading robots that simultaneously trade multiple financial instruments. The built-in Strategy Tester automatically downloads required tick history from the broker's server taking into account contract specifications, so the developer does not need to do anything manually. This makes it possible to easily and reliably reproduce trading environment conditions, including even millisecond intervals between the arrival of ticks on different symbols. In this article we will demonstrate the development and testing of a spread strategy on two Moscow Exchange futures.

We can express correlation between the two assets using a linear regression equation Y(X)=A(X)+B. Let's create a script CalcShowRegression_script.mq5, which takes two arrays of close prices, calculates coefficients and shows the distribution diagram with a regression line straight on the chart.

Regression coefficients are calculated using an ALGLIB function, and the values are drawn using graphic classes of the standard library.


Author: MetaQuotes Software Corp.

 

Thanks a lot for CalcShowRegression_script.mq5! Cool manual in the form of source code on ALGLIB and GraphPlot.

It's a pity that only one symbol to another was adjusted via LR, not two to one - ALGLIB would be more useful if they added USDRUB. But then the basket would be made of three symbols. And the TS would not be a classical spread one, but more complicated (but the results would be tastier). That is why, apparently, the author did not want to complicate the code of the presented TS in order not to repel the readers. After all, the main goal of the article is to attract, not to repel.

But it is easy to read, it is a good article. And I fully welcome the absence of MQL-inserts in the text of the article. Who really needs it - will look at the source code in full. And in the current form, the impression is good that it is easy to write, visualise and, most importantly, test and optimise multicurrencies in MT5.

 

A small remark to the article. Before building spread and QC, it is necessary to synchronise the charts of instruments on the time scale bar by bar. Because if there are missed bars (and there are), you will get a mess.

All IMHO)

 
Dmitriy Skub:

A small note to the article.

And logarithmise before LR. Otherwise, there is indeed a poor understanding of what is being done and why.
 
fxsaber:
And logarithmise before LR. Otherwise, there is really little understanding of what is being done and why.
By the way - it would be interesting to see how different the results would be with this.
 
Dmitriy Skub:

A small remark to the article. Before building spread and QC, it is necessary to synchronise the charts of instruments on the time scale bar by bar. Because if there are missing bars (and there are), you will get a mess.

The code will be a bit more complicated, but I suspect that, again, it will not affect the results much.
 
Rashid Umarov:
The code will be a bit more complicated, but I suspect that, again, it won't affect the results much.
If you take M1 and low-liquidity characters, it will affect the results a lot. Holes are the norm there.
 
fxsaber:

Why are ticks constantly ignored? In this article, LR is based on bars. Therefore, it cannot be used on small intervals - there are not enough bars.

Moreover, when there are ticks, it is possible to build a tick chart (both Bid and Ask, taking into account commissions of all incoming instruments) of the basket.

As if ticks are needed only for the tester and not for trade analysis.

On ticks would be cooler, like on steroids. Maybe someone can try it.
 
fxsaber:
If you take M1 and low-liquidity characters, it will affect the results greatly.
That would be a crapshoot, wouldn't it?
 
Rashid Umarov:
That'd be rubbish, wouldn't it?
I can't say, as I haven't tried it. But, definitely, holes should be taken into account. Moreover, even if the basket consists of N characters, filling holes and creating a multibar vector (matrix) is done in several lines. This bicycle should be available in MQL5 as a standard feature.
 
There is such a thing as interpolation :-)