Spread trading in Meta Trader - page 161

 
wise:
Not a grail. Accordingly, everyone has become uninterested. =)


Not interested at all! On the contrary. This branch has the necessary starting material and the majority have already "penetrated" and dispersed to specialized sites, and hopefully continue to trade successfully and gain experience!

By the way. On a related topic. Now there is a reason to get into buying the ZSK1-ZNK1 soybean spread (beans - flour, May contracts).

(I'm standing in the ZSK1-ZNK1 =2:3 ratio).

Here's the fundamental rationale for the entry, charts of multi-year seasonal spread trends :

 

And here is the current situation of this spread - see figure below.

You can clearly see from the line of the lower spread indicator that the seasonality has already started.

And you, wise, - say - not interesting.... And what are you interested in?

 

And here is another current option. Short term entry on tf=M30.

Tomorrow (i.e. tonight) there is an opportunity to buy the "commodity spread" oil - canadian futures.

buy CLH1 - sell 6CH1 =1^2

(or as follows: BUY QM + BUY USDCAD =1^1 - both instruments are BUY)

Prices of these instruments have diverged now, it can be easily seen on price lines in the window of the lower indicator. And (most likely) they will start to converge after the trades opening. And the spread indicator line is ready to turn up!

Closing of positions - very strictly at the point of convergence of price discs (green and blue)

We'll see how it ends tomorrow! (All previous last pair entries at the same price divergence were profitable - I've marked them with arrows)

 
How is the instrument volume ratio (idea) found and why is it constant?
 

It is not exactly constant. This is the ratio calculated by the indicator, taking into account the size of the tick in pips and the value of the pip in the deposit currency.

To the right is the ratio of sizes including volatility according to ATR - this is the best ratio to use in practical trading. And this is the ratio for which the spread line is drawn in the upper indicator.

int init() {
 

  // Определяем балансовые коэффициенты каждого инструмента
  kVol1=MarketInfo(Symbol1.Name, MODE_TICKVALUE)/MarketInfo(Symbol1.Name, MODE_TICKSIZE);
  kVol2=MarketInfo(Symbol2.Name, MODE_TICKVALUE)/MarketInfo(Symbol2.Name, MODE_TICKSIZE);
  

 int start() {
.... ... ...
// Расчет соотношения объемов для торговли.
  // Рассчитываются не абсолютные значения, а относительные, приведенные
  // к первому инструменту. При определении абсолютных объемов, исходя
  // из выбранной модели управления капиталом, следует сохранить 
  // рассчитанные пропорции.
  
  double volA1=1, volA2=EMPTY,     // Объем, рассчитанный по волатильности
         volP1=1, volP2=EMPTY,     // Объем, рассчитанный по цене открытия
         var1;

  // Если будет использоваться волатильность, рассчитываем объемы по волатильности
  if((VOL.Mode==2 || VOL.Mode==3) && 
     iBars(Symbol1.Name,0)>VOL.PeriodATR &&     // Достаточно ли баров в истории для расчета волатильности?
     iBars(Symbol2.Name,0)>VOL.PeriodATR) {
    var1=volA1*kVol1*iATR(Symbol1.Name,0,VOL.PeriodATR,1);
    volA2=var1/kVol2/iATR(Symbol2.Name,0,VOL.PeriodATR,1);
  }
  // Если будет использоваться цена открытия, рассчитываем объемы по цене открытия
  if(VOL.Mode==1 || VOL.Mode==3 || volA2==EMPTY) {
    var1=volP1*kVol1*iOpen(Symbol1.Name,0,0);
    volP2=var1/kVol2/iOpen(Symbol2.Name,0,0);
  } 

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

// Пишем комментарий в окне индикатора с правой стороны
  string sVolA1="",sVolA2="",sVolP1="",sVolP2="";
  if(volP2!=EMPTY) {
    sVolP1=DoubleToStr(volP1,2)+"= ";
    sVolP2=DoubleToStr(volP2,2)+"= ";
  }
  if(volA2!=EMPTY) {
    sVolA1=" ="+DoubleToStr(volA1,2);
    sVolA2=" ="+DoubleToStr(volA2,2);
  }
  DrawLabel(oSymb1, sVolP1+Symbol1.Name+sVolA1, 10, indicator_color1, 5);
  DrawLabel(oSymb2, sVolP2+Symbol2.Name+sVolA2, 10, indicator_color2,18);

And I usually, from practical experience - take this ratio:

buy CLH1 - sell 6CH1 =1^2

(you can also use BUY QM + BUY USDCAD =1^1 - both BUY instruments)
. Once again, closing of positions - strictly at the point of convergence of price discs (green and blue)

 

Thanks for the code, but I don't get the idea.

I suggest comparing our approaches to calculating ratios:

  1. Selects the FIs to compare.
  2. Build interval.
  3. The lot ratio is given out. Restrictions on calculation of lots (min. lot and min. lot step) are not imposed.
  4. The comparison is made through the real (unsmoothed) spread indicator for the specified lots.
 
leonid553:

...... ...
(or as follows: BUY QM + BUY USDCAD =1^1 - both BUY instruments)
. Once again, - close positions - strictly at the point of convergence of price discs (green and blue)

for this BUY QM + BUY USDCAD version the situation is as shown in the chart below.

Spread is built for ratio of QM:USDCAD positions = 1:1.4 - as demonstrated by the price line indicator calculated with volatility taken into account.

 
hrenfx:

I suggest comparing our approaches to ratio calculations:

  1. Selecting FIs for comparison
  2. Construction interval.
  3. The ratio of lots is issued. Restrictions on calculation of lots (min. lot and min. lot step) are not imposed.
  4. Comparison is performed through the real (not smoothed) spread indicator by specified lots.

It's not quite clear yet. This:

3. The ratio of lots is given. - What does it mean?

How is it given out? From a torch?

 

Let me rephrase: the volume and direction of positions that would eat up some amount of margin are given out. For example $1000:

  1. USDJPY = 0.5 lot ($500 margin at 100:1 leverage).
  2. USDCHF = -0.5 lots ($500 margin with 100:1 leverage).
 

I see. In essence, our approaches don't differ much. In the end, we come to point 4.

I think that my approach is still more expedient. My approach allows us to skip the first three points and go directly to the fourth point and then to the subsequent "smoothing" of the spread.

For example. With your approach for the "duo" CL - 6C = 1:1 (approximately) - when you get to the 4th point, you would find that you are essentially trading not a spread, but a single oil! Since with your assignment you get a strong bias towards oil.

With my approach - by setting in the spread the positions calculated by the indicator, in the majority of cases we obtain a balanced spread!

And it is balanced for all parameters - both for the volatility of the analyzed symbols and for their "specifications" (for specific characteristics - the point value, the size of the tick...).

Further - just correct dimensions for spread "averaging".

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

Maybe, I gave not a perfect example, because the Canadian and oil are not quite similar instruments, and they are traded on different floors.

Later (I will have lunch now) - I will give an example of SI-GC ( silver-gold)

Reason: