Spread trading in Meta Trader - page 190

 

Thanks leonid553!!!

The closer I get to the subject, the more logical this type of trading seems to be (there are clear trends). All the same, the subjective component is less here.

I mean trading by an Expert Advisor, not necessarily the one I meant in the above post.

And what kind of MM will be effective?

 

I find it difficult to say how appropriate and effective it is. I'm more comfortable trading spreads manually, visually assessing movement dynamics. MM should also be chosen by experience.

Besides not all spreads will be suitable for such short term trading. (I'm not even speaking about long term trading, there is no sense to keep the Expert Advisor on the timeframe of Н1 and higher! It's easier to manually look into the terminal several times a day)

We should carefully select the "tandems" on which the EA will make a profit. It is unlikely there will be many of such spreads. By the way, pair fills (1-2, at most) are very effective in spread trading.

====================================================

Back to the EA. Total result of two runs: +382-18= +364 dollars!

I have made the test above on the history of November 12 till now because there is no deeper history on F-contracts of gasoline and fuel oil in the terminal at the moment. I got a profitable result (honestly) on the second attempt! The first time (I have set closing parameters from a "light") I have charged too small closing profit (+25). The second time I've run with a closing profit of +46 - and got the total profit at once!

The number of trades in both runs should ideally be the same. In my gasoline-oil test - the number of trades differs slightly. I blame it on small holes in the history of quotes for gasoline or fuel oil. And/or - there is a bar mismatch in the overnight illiquid commodity market at low tf.

----------------

In the commentary on the chart and in the Expert Advisor code :

-purchase of spread (buy 1st instr. - sell 2nd instr.) conventionally called "hedge 2"

-sell spread (sell 1 - buy 2nd instr.) is conditionally called "hedge 1".

 

Hi all! Decided to work on the EA this morning to re-do the profit/loss display from pips to the deposit currency. But it didn't work.

I almost racked my brain for interaction of MODE_TICKVALUE, MODE_TICKSIZE, MODE_POINT and others.

Well, all right. Let me think, I will use the tandem (spread) of European Dax-Futsy indices! Their dimensions are the same (0.5, 1 tick = 5 pips) and this spread fits for this version of the Expert Advisor!

So, FDAXZ1-FTSEZ1=0.02^0.07

Since 1 tick = 5 pips, then(attention!) - stops in the Properties of the Expert Advis or CloseProfit and CloseLoss should be set strictly to a multiple of five !!!!!!!!! (Otherwise the log may return an error)

I left the same stops as in the previous gasoline/oil test, only I corrected 46 to 45. Note that this is only +9 ticks, so of course CloseProfit should be at least doubled.

TO BE CONTINUED ...

 

============

Open the dax chart FDAXZ1, M15 and swap the history (if one of the instruments does not have the full history set in the tester, the Journal will return a "division by zero" - Zero dividy). However, I have left the history since November 12.

Let's run the EA on dax:

==============

Now, let's load into the tester FTSEZ1, M15, and change positions in Properties of the EA the names of instruments!

And again we test it on the same history area. This is the result of "synchronous" running of Footsie:

=======================

Looking at the balance graphs, we can see that even though the number of trades does not coincide (it should!), the test is quite correct, since the equity lines are symmetric (opposite), as they should be ideally!

I.e. - the test was "successful"! Altogether, from November 14 up to now, we have gained 40+63=103 profit - more than +100 at position correlation FDAXZ1-FTSEZ1=0.02^0.07! It is clear (I repeat) that CloseProfit is too small in this test - it needs to be increased at least twofold.

Tester reports are on the download.

TO BE CONTINUED...

Files:
 

=================

To make the test of FDAX-FTSE more correct and close to the existing realities, let's increase CloseProfit parameter to +100! Loss, in this case, we set CloseLoss =300 (just out of curiosity!).

Running of Dax from November 12 till now gives such a result:

Synchronous run with FTSEZ1 gives us this result:

=============

Again we get a profitable final result! Moreover, the profit of each symbol is almost equal and total 68+54=+122 dollars from November 14 up to this date! Balance graphs are symmetrical as they should be, it shows satisfactory correctness of tests!

However, I should warn you that the tester does not consider the Ask-Bid spread on opening/closing positions of futures instruments. And meanwhile, the losses here are at least 1 tick per trade! Nevertheless, I think the test result is satisfactory, because the parameters (delta and stops) are taken, in fact, from the ceiling.

The automated optimization will probably be of little help here. But you never know. I hope that those visitors who are interested in the Expert Advisor will find time to spend it searching for the optimal parameters.

And if theydon't "get hooked", - they will post these parameters here, in this thread! Tester run reports are available for downloading.

Files:
 

You cannot test in this way. Or rather, you can, but you should modify your Expert Advisor specifically for testing.

Numbers are good, but I do not trust them because of the lag.

 

I'm not arguing, this EA is raw and for a more correct test-run, the current results should be written to a file and simultaneously the total equity (balance) line should be calculated with its subsequent drawing in excel! - Have I understood you correctly?

Then the result will be much more accurate. But such improvement is beyond my knowledge, since I'm not a professional programmer, but just a humble hobbyist, who needs to master the very beginning of MQL.

==================

p/s - the timing is very small! - It is visible on the good symmetry of the balance graphs. For the initial version and for the initial experiments, I think this version is quite suitable.

 
leonid553:

This EA is incomplete and for a more correct test-run, the current results should be written to a file and simultaneously the total equity (balance) line should be calculated with its subsequent drawing in excel! - did I understand you correctly?

No, you got it wrong. It won't remove the misalignment.
 

===========

There is some protection against desynchronisation in the code:

//проверяем наличие баров (синхронизируем работу) 
// - для инструментов, с разным началом/окончанием времени торговли
datetime Time_bar_Sl1 = iTime(Symbol_1,Period(), 0); 
datetime Time_bar_Sl2 = iTime(Symbol_2,Period(), 0);
//если текущий бар присутствует на обоих инструментах - работаем! 
if (Time_bar_Sl1 == Time_bar_Sl2) TRADE=true;   else TRADE=false;

TheXpert, what else can be done in this regard to increase the validity of the result?

 
leonid553:

There is some protection against desynchronisation in the code:

This protection will only work online. In the tester, it is unnecessary and maybe even harmful.

Proper synchronisation is done via iBarShift. And identity can only be achieved if all bars used for current situation calculation are synchronized.

Only this way (and only under certain conditions) gives a high probability of reliable results for the tester in 4.

Reason: