Statistical arbitration - page 4

 

Here is an example of the possibility of statistical quasi-arbitrage. QC is practically single. Only the size of the spread and stop-levelling does not allow us to take advantage of it. Such outliers are quite frequent.


 
ivandurak:
There are two indices: MICEX and RTS, it is clear that they correlate close to 1, in one perfect moment the cost of futures on the indices goes up to say 5%, although the average value is 0.5%. We buy one futures and sell another one, and when they meet again we make a reverse operation and fix profit. It is a simple example that lies on the surface and you can not fix it in time and use it to your advantage, because there are market makers. On the other hand no one prevents you to form your own portfolio (read index). Now count the number of possible portfolios consisting of 5 instruments from 36 possible, roughly about 300000. Try so many combinations manually, I can hardly imagine how. I have not dug in this direction and perhaps there is a rational basis.

No, we do everything with our hands, how can we trust a robot to choose our strategy? )))

As for MICEX and RTS market makers, their divergence and convergence is due to strengthening or weakening of the ruble,MICEX may be sometimes lower or sometimes higher up to 6 figures, and this happens not in a single moment but in several days, because of the great volatility of the RUR and markets this change occurs quite often. Profit should be taken automatically, where you can set the platform closing percentage yield or the currency of the deposit, or using tweezers. Everything works. Many forex dealers or SFD on them have EUROLLAR and BRAND. The profit can also be collected with your hands.)

 

Can you please tell me what needs to be changed so that the spread is adequately displayed from the first start of the indicator.

//+------------------------------------------------------------------+
//|                                                        Test7.mq5 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "2009, MetaQuotes Software Corp."
#property link        "http://www.mql5.com"
#property description "Test7"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrAqua
#property indicator_style1  STYLE_SOLID

//--- input parametrs

input string         Symbol1_Name = "EURUSD"; // Нога BUY
input string         Symbol2_Name = "GBPUSD"; // Нога SELL
input double         Symbol1_Vol  = 0.01;       
input double         Symbol2_Vol  = 0.02;        


//---- buffers
double         ExtStdDevBuffer[];

//--- global variables
double Symbol1_K, Symbol2_K;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
  //Определяем балансовые коэффициенты каждого инструмента
  Symbol1_K=SymbolInfoDouble(Symbol1_Name, SYMBOL_TRADE_TICK_VALUE)/SymbolInfoDouble(Symbol1_Name, SYMBOL_TRADE_TICK_SIZE);
  Symbol2_K=SymbolInfoDouble(Symbol2_Name, SYMBOL_TRADE_TICK_VALUE)/SymbolInfoDouble(Symbol2_Name, SYMBOL_TRADE_TICK_SIZE);
  
//---- define indicator buffers as indexes
   SetIndexBuffer(0,ExtStdDevBuffer,INDICATOR_DATA);
   ArraySetAsSeries(ExtStdDevBuffer,true);                             // индексация массива как таймсерия
   PlotIndexSetString(0,PLOT_LABEL,"SPREAD");

  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
  //--- variables of indicator
  int i, limit;
  
   if(prev_calculated>0)
     {limit=1;}
   else
     {limit=prev_calculated;}
    
  //--- main cycle
  for(i=limit-1;i>=0;i--)
  {
      ExtStdDevBuffer[i] = (Symbol1_Vol*Symbol1_K*iClose(Symbol1_Name,i) -  Symbol2_Vol*Symbol2_K*iClose(Symbol2_Name,i));
  }
  
  Comment("Symbol1_K =",Symbol1_K,"\n",
          "Symbol2_K =",Symbol2_K,"\n",
          "close_1[1] =",iClose(Symbol1_Name,1),"\n",
          "close_2[1] =",iClose(Symbol2_Name,1),"\n",
          "close[1] =",close[rates_total-1]);
          
          
   
  return(rates_total);
}

//-----------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|Возвращает значение цены закрытия указанного параметром shift     | 
//|бара с соответствующего графика (symbol, timeframe).              |
//|В случае ошибки функция возвращает 0.                             |
//+------------------------------------------------------------------+
double iClose(string Symb,int Shift)
  {
   double Array[1];
   int Copied=CopyClose(Symb,PERIOD_CURRENT,Shift,1,Array);
   if(Copied!=1) return(0);
   return(Array[0]);
  }


In the pictures, the bottom spread indicator of the branch author.

Files:
Test7.mq5  4 kb
 

Ahem, I'll pick up the thread.

At this point, I can argue that the analysis of the two majors amounts to an analysis of their cross:

If there are any objections, I am happy to hear them.

In this regard, MM comes first. Let's have a brainstorming session.

Who thinks what is the best trading tactic for oscillators?

 
Heroix:

Ahem, I'll pick up the thread.

At this point, I can argue that the analysis of the two majors amounts to an analysis of their cross:

If there are any objections, I am happy to hear them.

In this regard, MM comes first. Let's have a brainstorming session.

Who thinks what is the best trading tactic for oscillators?

I dug around this subject a little. Imho, we do not need to analyze the majors but their total equity (portfolio equity): the difference between the portfolio and the cross at different weight coefficients of the majors' participation. In general, we should select a portfolio of instruments with such weight coefficients so that their aggregate equity would have the smallest average square deviation and the largest approximation to a straight line. As for the application of such a portfolio. If the linear regression of the equity is horizontal, we buy from the borders of the channel (in this case, the RMS value should be maximum). If the equity has a trend inclination angle, it is clear even to me. The question remains as to how long the portfolio equity maintains its properties after the optimization period. I'll get to work and try to draw an indicator a bit later.
 
That's just it, the synthetic almost immediately flies out of the channel... I can assume with a 0.5 probability. This suggests that there are no advantages compared to classic single instrument trading.
 
ivandurak:
In general, it is necessary to select a portfolio of instruments with such weighting coefficients that their aggregate equity has the smallest standard deviation, the closest approximation to a straight line.
This is the task that has been solved here.
Recycle2 - MQL4 Code Base
  • www.mql5.com
Recycle2 - MQL4 Code Base: технические индикаторы для МТ4
 
Heroix:

At this point, I can argue that analysing the two majors amounts to analysing their cross:

Hence:

hrenfx:

True only for EURUSD^k1 * GBPUSD^k2, where k1 = 0.5 and k2 = -0.5.

At other ratios (|k1| + |k2| = 1) your statement is incorrect.

 
hrenfx:
That's exactly the problem solved here.
Almost yes. Only I want to do it with several variations. Unfortunately the code is not commented there, so it's better to write it yourself. What can be seen from the video, the summarized equity has some inertia on stationarity. Note on the video - after the synthetic channel is found the trend starts next.
 
You should not watch the video, but move the construction interval yourself with the mouse. Fortunately, the toolkit immediately (without lags) rebuilds the synthetic, showing it beyond the construction interval as well (the red triangles are the first zero crossing of the synthetic outside the construction interval).