Pair trading and multicurrency arbitrage. The showdown. - page 15

 
mytarmailS #:

I apologise for being inaccurate in my question, I meant what spread (commission) do you put into the profit curve calculation....

real or constant.


I plot a linear regression between two assets (classical).

Please give me an example. I do not know exactly on what principle this indicator is calculated. I haven't really looked into it.

 
Roman Poshtar #:

Please give me an example. I do not know exactly on what principle this indicator is calculated. I haven't learnt much about it.

Let's not talk about everything at once.

My question is still relevant

 
Roman Shiredchenko #:

If you don't mind, please write down the formula for balancing volumes....

What is the divergence of conventional indicators and how to identify it?

As a function - MT4

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

//+-----------------------------+
enum BalLot {     // Balance Lot Size
     BLS1 = 0,    // BalanceVolatility
     BLS2 = 1     // BalancePrice
}; 

extern string    DIFF_PairI           = "EURUSD"; 
extern string    DIFF_PairII          = "GBPUSD";  

extern string    LOT_OPTIONS          = "===================================";
extern double    LotSize              = 0.1;
extern BalLot    BalanceLotSize       = BLS1;
extern int       VOL_PeriodATR        = 144; 

//+==================================================================+
//|     Возвращает сбалансированный / уравновешенный размер лота     |
//+==================================================================+
double getLotSize(string CurrentPair)  {

      //+-------------------------------+
      // Определяем балансовые коэффициенты каждого инструмента
      double kVol1 = SymbolInfoDouble(DIFF_PairI, SYMBOL_TRADE_TICK_VALUE)  / SymbolInfoDouble(DIFF_PairI, SYMBOL_TRADE_TICK_SIZE);
      double kVol2 = SymbolInfoDouble(DIFF_PairII, SYMBOL_TRADE_TICK_VALUE) / SymbolInfoDouble(DIFF_PairII, SYMBOL_TRADE_TICK_SIZE);

      //--------------------------------------------------------------------  
      // Рассчитываются не абсолютные значения, а относительные, приведенные
      // к первому инструменту. 
  
      double Lot_Volat1 = LotSize, Lot_Volat2 = 0,     // Объем, рассчитанный по волатильности
             Lot_Price1 = LotSize, Lot_Price2 = 0,     // Объем, рассчитанный по цене открытия
             var1;
  
      //+=======================================+
      //| рассчитываем объемы по волатильности  |
      //+---------------------------------------+
      if ( iBars(DIFF_PairI, 0) < VOL_PeriodATR+1 )   {
           if  (Language == Lang1) Message("LOT: Calculation Not possible, Download quotes - "+DIFF_PairI);
           else                    Message("LOT: Расчет Невозможен, Подкачайте котировки-"+DIFF_PairI);        
           return(0);
      }
      if ( iBars(DIFF_PairII, 0) < VOL_PeriodATR+1 )   {
           if  (Language == Lang1) Message("LOT: Calculation Not possible, Download quotes - "+DIFF_PairII);
           else                    Message("LOT: Расчет Невозможен, Подкачайте котировки-"+DIFF_PairII);        
           return(0);
      }

      if (BalanceLotSize == BLS1)  { 
          var1  = Lot_Volat1*kVol1*iATR(DIFF_PairI,0,VOL_PeriodATR,1);
          if (kVol2 != 0 && iATR(DIFF_PairII,0,VOL_PeriodATR,1) != 0)  {
              Lot_Volat2 = var1/kVol2/iATR(DIFF_PairII,0,VOL_PeriodATR,1);
          }else{
              LotMessage();
              return(0);
          }
          //+---------------------+
          if (Lot_Volat2 < LotSize)  {
              if (Lot_Volat2 != 0)   {
                  Lot_Volat1 *= Lot_Volat1/Lot_Volat2; 
              }else{
                  LotMessage();
                  return(0);              
              }
              Lot_Volat2  = LotSize;
          }
          //+---------------------+
          if (CurrentPair == DIFF_PairI) return( NormalizeDouble(Lot_Volat1, 2) );//return( normalizeLotSize(DIFF_PairI,  Lot_Volat1) );
          else                           return( NormalizeDouble(Lot_Volat2, 2) );//return( normalizeLotSize(DIFF_PairII, Lot_Volat2) );
      }
   
      //+=======================================+
      //| рассчитываем объемы по цене открытия  |
      //+---------------------------------------+
      if (BalanceLotSize == BLS2) {
          var1  = Lot_Price1*kVol1*iOpen(DIFF_PairI,0,0);
          if (kVol2 != 0 && iOpen(DIFF_PairII,0,0) != 0)   {
              Lot_Price2 = var1/kVol2/iOpen(DIFF_PairII,0,0);
          }else{
              LotMessage();
              return(0);          
          }
          //+----------------------+
          if (Lot_Price2 < LotSize)  {
              if (Lot_Price2 != 0)   {
                  Lot_Price1 *= Lot_Price1/Lot_Price2; 
              }else{
                  LotMessage();
                  return(0);              
              }
              Lot_Price2  = LotSize;
          }  
          //+----------------------+
          if (CurrentPair == DIFF_PairI) return( NormalizeDouble(Lot_Price1, 2) );//return( normalizeLotSize(DIFF_PairI,  Lot_Price1) );
          else                           return( NormalizeDouble(Lot_Price2, 2) );//return( normalizeLotSize(DIFF_PairII, Lot_Price2) );
      }

      //+-------------------------------+
      return(0);
}
 
Sergiy Podolyak #:

As a function - MT4

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


I am not familiar with those terms in your question. I understand about lots, thanks. What about the spread?

 
Sergiy Podolyak #:
As a function - MT4
Thank you - I will copy it for myself in my work.
 
While waiting for an answer from Sergiy Podolyak, I will add an owl on stochastics and finish version 3. For now I will add closing on profit, see what will come out. To the moderator, please put version 3 in the header.
Sergiy Podolyak
Sergiy Podolyak
  • 2018.12.05
  • www.mql5.com
Профиль трейдера
 

According to version 3, apparently this is not the end, we need to work with the second indicator from the kit. Let's move on. In an hour will be version V3_1 with closing on profit.

I also ask all participants to offer their variants of determining discrepancies, bundles, calculating the spread, etc.

We will not chew for a long time, we write an owl, throw it into the tester and watch.

 
Roman Poshtar #:

According to version 3, apparently this is not the end, we need to work with the second indicator from the kit. Let's move on. In an hour will be version V3_1 with closing on profit.

I also ask all participants to offer their variants of determining discrepancies, bundles, spread calculation, etc.

We will not chew for a long time, we write an owl, throw it in the tester and look.

Trading cross is the same as trading major. I told you! And those pairs that have diverged may never get back together, but diverge even more. You have to trade one pair and be guided by two completely different but from a country that is geographically close.
 
Vladislav Vidiukov #:
Trading a cross is the same as trading a major. I told you! And those pairs that have diverged may never come together, but diverge even more. It is necessary to trade 1 pair and be guided by 2 completely different but from a country that is geographically close.

I've tested on 2 pairs and on crosses the results are different. Two pairs are better, I don't know what the reason is. Maybe on exotics too big spread. Thanks to moderator for promptness. I think further )

 
Roman Poshtar #:

I've tested on 2 pairs and the crosses have different results. Two are better, I don't know what the reason is. Perhaps on exotics too big spread. Thanks to moderator for promptness. I think further )

The reason is that there is more movement on 2 pairs, as it is not "eaten".
Reason: