Spread trading in Meta Trader - page 15

 
getch >>:

Торговля спредом - это статистический арбитраж. Использование статистических корреляций между различными синтетическими торговыми инструментами.

Если корреляции нет, то это уже классичесая торговля сразу с несколькими торговыми инструментами.

Not so. Spread trading is pairs trading, trading one synthetic product which, as in this case, consists of one index long and another short. Correlation between the two indices is not necessary, co-integration is important.

Statistical arbitrage is to buy all undervalued assets and simultaneously sell all overvalued assets, the correlation between specific assets is not important, even the cointegration is not very important. The important thing is the statistics - the large number of assets.

Sometimes pairs trading is called statistical arbitrage, they are very close, but it is still better to distinguish them.

 

I would still like to understand the terminology.

What are Asset, Cointegration and Correlation?

 
rid >>:


Это можно реализовать (в самом простом виде) вот так:

При этом позиции можно открывать вручную - скриптом И.Кима (есть на его сайте), позволяющим задавать магик при открытиии позиции.

http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&func=fileinfo&id=47 и

http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&func=fileinfo&id=46

Т.к. я заложил по магику (Magic и Magic2) вид "хеджа" в коде - это необходимо, т.к. разные позиции у нас в обоих видах "хеджа" обсчитываются и закрываются по разным ценам, - - по аскам и бидам обоих тикеров #I .

rid,

again, sorry for the naive question - is this a ready-made Expert Advisor? or do you need to upgrade Kim's e-CloseByProfit with it?

 
rid писал(а) >>

That's where the problem surfaced. Where I wasn't expecting it to come from.

With this display of the current "hedge" profit in the comment - the profit of the second character (the second trade) is not displayed quite correctly!

Here's why. The Expert Advisor "stands" on the first symbol chart and all the information changes with the arrival of a new tick for this symbol.

But it may happen that during this time, there are several ticks on the second instrument! But this information is not coming to the comment ("The current profit of the 2nd symbol BUY-UP =") because a new tick has not come to the chart (where the EA is) of the first symbol yet!

How do I do it ? How to avoid a mismatch ?

Please advise.

The easiest solution is to run the same Expert Advisor (or the profit calculation function) on a parallel instrument.

You can also give orders to open/close positions for pairs from any EA.

We need to make sure that there is no doubling, for example, the Expert Advisor that has given earlier the command to open

(the tick for its symbol came earlier) sets a flag in a global variable of the terminal and the other EA will rest.

 

to Den2000 (in your personal message)

As a matter of fact, it is a ready-made Expert Advisor (for Broko), but it works only for closing of opened positions ("hedges") opened by the I.Kim's scripts mentioned at the links.

Only for futures instruments with tickers.

The only thing that should be put at the very end of the code (outside the START function) is Kim's functions (right in order, one by one):

PriceOpenLastPos() https://forum.mql4.com/ru/11287/page63#126982

ClosePosFirstProfit(); https://www.mql5.com/ru/forum/107476/page14#76382

ClosePosBySelect() https://www.mql5.com/ru/forum/107476/page13

GetNameOP(int op) https://www.mql5.com/ru/forum/107476/page6#69097

NumberOfPositions() (for comment block) https://www.mql5.com/ru/forum/107476/page18#78397

However, I believe all these functions (except for the first one) are probably in Kim's e-CloseByProfit and can be taken from there.

And in the global variables we should add (from above) :

extern string ___ = "=== Прочие Параметры советника  ===";

extern bool   UseSound      = True; // Использовать звуковой сигнал
extern string NameFileSound = "expert.wav";// Наименование звукового файла
extern color  clCloseBuy    = Yellow;    // Цвет закрытия покупки
extern color  clCloseSell   = Green;    // Цвет закрытия продажи
extern int    NumberOfTry   = 10;      // Количество попыток
string SoundSuccess  = "ok.wav";      // Звук успеха
string SoundError    = "timeout.wav";// Звук ошибки
int        Slippage        = 50;   // Проскальзывание цены при закрытии
//-- Подключаемые модули --
#include <stderror.mqh>
#include <stdlib.mqh>


//----------------------------------------------------------

It is necessary to open hedges using the above mentioned Kim's scripts that allow setting a magik. The Expert Advisor recognizes and closes the hedge type according to the magiks specified at the opening.

Moreover, in case of Hedge=(Buy 2nd inst + Sell 1st inst), you should set magic = EA's magic.

To hedge = (buy 1 + sell 2) you should enter 1 more magic (i.e. EA magic +1).

The first instr-ut is the one on the chart of which the EA is installed.

 
goldtrader >>:

Наиболее простое решение - запустить аналогичный эксперт (или функцию расчёта прибыли) на параллельном инструменте.

Также можео подавать команды на открытие/закрытие поз по парам из любого советника.

При этом нужно предусмотреть чтобы не было дублирования, например, тот советник, который раньше дал команду на открытие

(тик по его инструменту пришёл раньше) выставляет флаг через глобальную переменную терминала и другой советник отдыхает.

Yeah... Seems - easier, like Fduch's, to do as a looped script...

 
gurman >>:

Спасибо, суть то мне понятна... я и сам эту "тему" пытаюсь пользовать. Тока в кодах я "ни бум-бум", по-этому пользуюсь разными подручными приспособлениями. Вот, ищу что-нибудь подходящее для себя.

А Вы свой советник планируете в свободный доступ или как...? Было бы интересно попробовать...


Not yet. It's still raw, hanging by a thread. I'll probably not be posting my final version anytime soon.

//-----------------------------

But you can contact a professional programmer here on this forum. They will quickly write an EA for a similar and reasonable price.

All the more so, that the essence is clear to you and the terms of reference you can write sensibly.

 
Fduch >>:

Мне пришлось немного изменить формат - теперь торгует не советник, а скрипт. Скрипт с таким int start():

Теоретически, можно использовать такую конструкцию и в советнике, но я не пробовал.. Возможно, есть какая-то специфика вроде ограничения времени выполнения в main советников, хотя вряд ли.

Everything is fine. The EA has been running for a week with this design. The only disadvantage is that I have no access to properties.

Goldtrader >>

The easiest solution is to run a similar Expert Advisor (or profit calculation function) on a parallel instrument.

You can also send commands to open/close positions on pairs from any EA

.

No, not that case. All in one EA, and with different mechanism for opening / closing by instrument.

 

All instruments have the same parasitic EA, which creates an artificial tick on the chart where the multicurrency EA is hovering.

But the looped variant seems more correct.

 

TheXpert писал(а) >>


Everything is fine. The EA has been running for a week with this design. The only disadvantage is that we cannot access the properties.

You can easily access the properties of the looped EA. You can temporarily disable the button "Expert Advisors" and edit the properties. The most important thing is not to forget to enable the button again.

Reason: