Русский 中文 Español Deutsch 日本語 Português
Superposition and Interference of Financial Securities

Superposition and Interference of Financial Securities

MetaTrader 4Examples | 2 June 2009, 09:46
2 257 18
Khristian Piligrim
Khristian Piligrim

"As you cannot step into the same river twice,
You cannot enter the same market twice.
Everything flows, and nothing abides…
"

DAO Piligrimm



Introduction

From lectures in physics we know about the principle of interference of light. Interference is the strengthening or weakening of waves of the same frequency that meet in one point. According to electrostatics, intensity of charges system field is equal to the vector sum of intensity of fields that would be produced by each of the system charges separately.

Taking these two laws as the basis, I decided to check their performance on financial securities of the Forex market. For this purpose I took the following as an axiom: any currency pair at each moment of time shows the ratio of one currency to another; besides, each national currency changes in time not only relatively to another currency, but also relatively to itself.

Change of a national currency with the flow of time relatively to itself is influenced by the change of the whole complex of economic factors in the country, to which the currency belongs. The resulting price in a chart of each security is obtained as a superposition of two vectors that change in time; thereat vectors change both according to phase and amplitude. Vectors are derivatives of superpositions of all economic factors inside a country, to which the currency belongs, as well as of international factors.

Let's take as an example the currency pair EURUSD. The resulting movement in a price chart is formed the following way taking into account national currency EUR and USD changing with the flow of time:

1). EURUSD grows, if:

а). EUR – grows and USD – falls;

b). EUR – grows and USD – doesn't change;

c). EUR – doesn't change and USD – falls;

d). EUR – grows and USD – grow, but slower than EUR;

2). EURUSD – falls, if:

а). USD – grows and EUR – falls;

b). USD – grows and EUR – doesn't change;

c). USD – doesn't change and EUR – falls;

d). USD – grows and EUR – grows, but slower than USD;

3). EURUSD – doesn't change, if:

а). USD – doesn't change and EUR – doesn't change;

b). USD – grows and EUR – grows, but at the same speed as USD;

c). USD – falls and EUR – falls, but at the same speed as USD.

The more factors influence the behavior of a currency pair, the more difficult it is to evaluate its behavior and make up future forecasts. Therefore, if we managed to extract components of a currency pair, values of a national currency that change with the time, we could considerably delimit the freedom of national currency movement as compared to the currency pair with this currency, as well as the number of factors influencing its behavior. As a result we would increase the accuracy of its behavior estimation and future forecasting. How can we do that?



Principle of Superposition and Interference of financial Securities

So, the task is defined the following way: we have a currency pair, for example, EURUSD. We need to divide this pair into its components - EUR and USD. To solve this task I took available cross-courses of EUR and USD with other currencies: EURGBP, EURJPY, EURAUD, EURCHF, EURCAD, EURNOK, EURSEK, EURDKK, EURNZD, EURSGD, EURHKD, USDCHF, USDJPY, USDCAD, USDNOK, USDSEK, USDDKK, USDSGD, USDHKD, USDMXN, USDZAR, GBPUSD, AUDUSD, NZDUSD. Having data on cross-courses of USDMXN, USDZAR, I didn't have corresponding cross-courses with EUR in my brokerage company. But this can be easily fixed: EURMXN = EURUSD * USDMXN; EURZAR = EURUSD * USDZAR.

On the first stage of solving the task we should bring all currencies to a single scale. For this purpose let's calculate the scaling coefficient for each currency pair as the averaged value of Close for a corresponding currency pair on the sample length LengthSample. After that dividing price values of each currency pair along the whole length of the sample by the scaling coefficient corresponding to this currency pair, we will obtain currency pairs brought to a single scale.

On the second stage for getting EUR and USD let's apply laws of superpositions and interference to corresponding groups of currency pairs, containing EUR and USD correspondingly; and average results by the number of securities used.

EUR = (EURUSD + EURGBP + EURJPY + EURAUD + EURCHF + EURCAD + EURNOK + EURSEK + EURDKK + EURNZD + EURSGD + EURHKD + EURMXN + EURZAR)/14;

USD = (USDCHF + USDJPY + USDCAD + USDNOK + USDSEK + USDDKK + USDSGD + USDHKD + USDMXN + USDZAR + 1/GBPUSD + 1/AUDUSD + 1/NZDUSD + 1/EURUSD)/14;

Accepting a priory that a currency pair is formed of two vectors of national currencies, and changes of phases of these vectors in time are not synchronous but are formed mostly under the influence of economic factors of a certain country, we can draw the following conclusion:

At the superposition of cross-courses of various currencies the constituent of a numerator, according to the interference law, strengthens due to the coincidence of phases; constituents of a denominator are to a larger extent mutually compensated due to the noncoincidence of phases.

Fig. 1 shows charts of EUR and USD calculation results according to the above formulas. The pink color shows EUR, blue - USD, light blue - EURUSD.

Fig.1

Now let's estimate, what is the calculation error of EUR and USD resulting from the incomplete compensation of denominator constituents in the above formulas. For this purpose let's build charts of EURUSD, light blue line in fig. 2, and of the ratio of the calculated EUR to the calculated USD, red line in fig. 2.

Fig.2

From the above charts it is clear that phase distortions of EUR and USD obtained by the superposition and interference of currency cross-courses are insignificant, but the amplitude error is considerable which points to the incomplete compensation of constituents of national currencies that are parts of EUR and USD cross-courses. However, it can be noted that the non-linear character of the error from bar to bar is small, this enables us to perform the error compensation on the current bar by including the compensator from the previous bar to the above formulas.

The compensating error is calculated as follows:

  Och   = EURUSD * USD / EUR;


Introducing the obtained error value into EUR and USD calculation formulas as a compensating element from the previous bar at the calculation of the current one, we obtain quite an acceptable calculation error for most applied problems. Fig. 3 shows calculation results after the compensation, charts of EURUSD, light blue line in fig. 3, and of the ratio of the calculated EUR to the calculated USD, red line in fig. 3. As seen from the charts, obtained results are much better than before the compensation.

Fig.3

As it has been said, phase distortions introduced by the offered method of extraсting components EUR and USD from EURUSD are insignificant, but the further from the zero bar we the analyzed history is, as well as EUR and USD obtained based on this history are, the stronger will be the effect of history gaps. When bars are omitted, because of history gaps the synchronization of cross-courses of different currencies is disturbed. This results in the appearance of phase distortions in the calculated EUR and USD relative to EURUSD.

The deeper into history we dive, or the smaller timeframes we use in or calculations, the stronger will be the effect of history gaps and the larger will be resulting phase distortions. Fig. 4 shows charts that prove the above statement. These charts are continuation of charts in fig. 3 deeper into history. Because of the accumulated error that is connected with the omission of separate history bars of various securities used, we see considerable phase distortions. In order to solve this problem we should use history data of higher quality or special means of filling out those history gaps.

Fig.4

Having calculated EUR and USD, we can calculate any other national currencies.


GBP = (EUR / EURGBP + GBPUSD * USD) / 2;
JPY = (EUR / EURJPY + USD / USDJPY) / 2;
AUD = (EUR / EURAUD + AUDUSD * USD) / 2;
CHF = (EUR / EURCHF + USD / USDCHF) / 2;
CAD = (EUR / EURCAD + USD / USDCAD) / 2;
NOK = (EUR / EURNOK + USD / USDNOK) / 2;
SEK = (EUR / EURSEK + USD / USDSEK) / 2;
DKK = (EUR / EURDKK + USD / USDDKK) / 2;
NZD = (EUR / EURNZD + NZDUSD * USD) / 2;
SGD = (EUR / EURSGD + USD / USDSGD) / 2;
HKD = (EUR / EURHKD + USD / USDHKD) / 2;
MXN = (EUR / EURMXN + USD / USDMXN) / 2;
ZAR = (EUR / EURZAR + USD / USDZAR) / 2;

Fig. 5 shows series of above calculated currencies represented in one chart. EURUSD – light blue color, EUR – pink color, USD – blue color, GBP – red color, JPY – brown color, AUD – purple, CHF – yellow, CAD – black.

Fig.5

The above described algorithm of national currency calculation using the principle of superposition and interference is implemented in my indicator SuperPosition, which is attached to the article.

//+------------------------------------------------------------------+
//|                                                SuperPosition.mq4 |
//|                                       Copyright © 2009,Piligrimm |
//|                                     mailto: piligrimm_fx@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009,Piligrimm"
#property link      "mailto: piligrimm_fx@mail.ru"
#property indicator_separate_window   
#property indicator_buffers 3
#property indicator_color1 Magenta
#property indicator_color2 Blue
#property indicator_color3 Aqua
//---- input parameters
extern int LengthSample=1000;
int i,j;
double GL[][81],EURClose[],USDClose[],EURUSDClose[],EURHigh[],USDHigh[],EURUSDHigh[],EURLow[],USDLow[];
double GBPClose[],JPYClose[],AUDClose[],CHFClose[],CADClose[],NOKClose[],SEKClose[],EURUSDLow[],Kf[27];
double DKKClose[],NZDClose[],SGDClose[],HKDClose[],MXNClose[],ZARClose[],SGDLow[],HKDLow[],MXNLow[];
double GBPHigh[],JPYHigh[],AUDHigh[],CHFHigh[],CADHigh[],NOKHigh[],SEKHigh[],DKKLow[],NZDLow[];
double DKKHigh[],NZDHigh[],SGDHigh[],HKDHigh[],MXNHigh[],ZARHigh[],ZARLow[],CloseOch,HighOch,LowOch;
double GBPLow[],JPYLow[],AUDLow[],CHFLow[],CADLow[],NOKLow[],SEKLow[];
//---- buffers

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   
       SetIndexBuffer(0,EURClose);               // Assigning an array to a buffer
   //    SetIndexBuffer(0,EURHigh);              // Assigning an array to a buffer
   //    SetIndexBuffer(0,EURLow);               // Assigning an array to a buffer
       SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);//   Line style
       SetIndexBuffer(1,USDClose);               // Assigning an array to a buffer
   //    SetIndexBuffer(1,USDHigh);              // Assigning an array to a buffer
   //    SetIndexBuffer(1,USDLow);               // Assigning an array to a buffer
       SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,2);//   Line style
       SetIndexBuffer(2,EURUSDClose);            // Assigning an array to a buffer
   //    SetIndexBuffer(2,EURUSDHigh);           // Assigning an array to a buffer
   //    SetIndexBuffer(2,EURUSDLow);            // Assigning an array to a buffer
       SetIndexStyle (2,DRAW_LINE,STYLE_SOLID,2);//   Line style
       
       ArrayResize(GL, LengthSample+1);
       ArrayResize(EURClose, LengthSample);
       ArrayResize(USDClose, LengthSample);
       ArrayResize(GBPClose, LengthSample);
       ArrayResize(JPYClose, LengthSample);
       ArrayResize(AUDClose, LengthSample);
       ArrayResize(CHFClose, LengthSample);
       ArrayResize(CADClose, LengthSample);
       ArrayResize(NOKClose, LengthSample);
       ArrayResize(SEKClose, LengthSample);
       ArrayResize(DKKClose, LengthSample);
       ArrayResize(NZDClose, LengthSample);
       ArrayResize(SGDClose, LengthSample);
       ArrayResize(HKDClose, LengthSample);
       ArrayResize(MXNClose, LengthSample);
       ArrayResize(ZARClose, LengthSample);       
       ArrayResize(EURHigh, LengthSample);
       ArrayResize(USDHigh, LengthSample);       
       ArrayResize(GBPHigh, LengthSample);
       ArrayResize(JPYHigh, LengthSample);
       ArrayResize(AUDHigh, LengthSample);
       ArrayResize(CHFHigh, LengthSample);
       ArrayResize(CADHigh, LengthSample);
       ArrayResize(NOKHigh, LengthSample);
       ArrayResize(SEKHigh, LengthSample);
       ArrayResize(DKKHigh, LengthSample);
       ArrayResize(NZDHigh, LengthSample);
       ArrayResize(SGDHigh, LengthSample);
       ArrayResize(HKDHigh, LengthSample);
       ArrayResize(MXNHigh, LengthSample);
       ArrayResize(ZARHigh, LengthSample);
       ArrayResize(EURLow, LengthSample);
       ArrayResize(USDLow, LengthSample);
       ArrayResize(GBPLow, LengthSample);
       ArrayResize(JPYLow, LengthSample);
       ArrayResize(AUDLow, LengthSample);
       ArrayResize(CHFLow, LengthSample);
       ArrayResize(CADLow, LengthSample);
       ArrayResize(NOKLow, LengthSample);
       ArrayResize(SEKLow, LengthSample);
       ArrayResize(DKKLow, LengthSample);
       ArrayResize(NZDLow, LengthSample);
       ArrayResize(SGDLow, LengthSample);
       ArrayResize(HKDLow, LengthSample);
       ArrayResize(MXNLow, LengthSample);
       ArrayResize(ZARLow, LengthSample);
       ArrayResize(EURUSDClose, LengthSample); 
       ArrayResize(EURUSDHigh, LengthSample);      
       ArrayResize(EURUSDLow, LengthSample);
       

//----

   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
//
int start()
    {//1

   for (i=0; i<=LengthSample; i++)                    
     {//2
       GL[i][0]=  iClose("EURUSD",0,i); 
       GL[i][1]=  iClose("EURGBP",0,i); 
       GL[i][2]=  iClose("EURJPY",0,i); 
       GL[i][3]=  iClose("EURAUD",0,i); 
       GL[i][4]=  iClose("EURCHF",0,i); 
       GL[i][5]=  iClose("EURCAD",0,i); 
       GL[i][6]=  iClose("EURNOK",0,i); 
       GL[i][7]=  iClose("EURSEK",0,i); 
       GL[i][8]=  iClose("EURDKK",0,i); 
       GL[i][9]=  iClose("EURNZD",0,i); 
       GL[i][10]= iClose("EURSGD",0,i); 
       GL[i][11]= iClose("EURHKD",0,i); 
       GL[i][12]= iClose("USDCHF",0,i); 
       GL[i][13]= iClose("USDJPY",0,i); 
       GL[i][14]= iClose("USDCAD",0,i); 
       GL[i][15]= iClose("USDNOK",0,i); 
       GL[i][16]= iClose("USDSEK",0,i); 
       GL[i][17]= iClose("USDDKK",0,i); 
       GL[i][18]= iClose("USDSGD",0,i); 
       GL[i][19]= iClose("USDHKD",0,i);
       GL[i][20]= iClose("USDMXN",0,i); 
       GL[i][21]= iClose("USDZAR",0,i); 
       GL[i][22]= iClose("GBPUSD",0,i); 
       GL[i][23]= iClose("AUDUSD",0,i); 
       GL[i][24]= iClose("NZDUSD",0,i); 
       GL[i][25]= GL[i][0]*GL[i][20];  //Close"EURMXN"
       GL[i][26]= GL[i][0]*GL[i][21];  //Close"EURZAR"
       GL[i][27]= iHigh ("EURUSD",0,i); 
       GL[i][28]= iHigh ("EURGBP",0,i); 
       GL[i][29]= iHigh ("EURJPY",0,i); 
       GL[i][30]= iHigh ("EURAUD",0,i); 
       GL[i][31]= iHigh ("EURCHF",0,i); 
       GL[i][32]= iHigh ("EURCAD",0,i); 
       GL[i][33]= iHigh ("EURNOK",0,i); 
       GL[i][34]= iHigh ("EURSEK",0,i); 
       GL[i][35]= iHigh ("EURDKK",0,i); 
       GL[i][36]= iHigh ("EURNZD",0,i); 
       GL[i][37]= iHigh ("EURSGD",0,i); 
       GL[i][38]= iHigh ("EURHKD",0,i); 
       GL[i][39]= iHigh ("USDCHF",0,i); 
       GL[i][40]= iHigh ("USDJPY",0,i); 
       GL[i][41]= iHigh ("USDCAD",0,i); 
       GL[i][42]= iHigh ("USDNOK",0,i); 
       GL[i][43]= iHigh ("USDSEK",0,i); 
       GL[i][44]= iHigh ("USDDKK",0,i); 
       GL[i][45]= iHigh ("USDSGD",0,i); 
       GL[i][46]= iHigh ("USDHKD",0,i);
       GL[i][47]= iHigh ("USDMXN",0,i); 
       GL[i][48]= iHigh ("USDZAR",0,i); 
       GL[i][49]= iHigh ("GBPUSD",0,i); 
       GL[i][50]= iHigh ("AUDUSD",0,i); 
       GL[i][51]= iHigh ("NZDUSD",0,i); 
       GL[i][52]= GL[i][27]*GL[i][47];  //High"EURMXN"
       GL[i][53]= GL[i][27]*GL[i][48];  //High"EURZAR"
       GL[i][54]= iLow  ("EURUSD",0,i); 
       GL[i][55]= iLow  ("EURGBP",0,i); 
       GL[i][56]= iLow  ("EURJPY",0,i); 
       GL[i][57]= iLow  ("EURAUD",0,i); 
       GL[i][58]= iLow  ("EURCHF",0,i); 
       GL[i][59]= iLow  ("EURCAD",0,i); 
       GL[i][60]= iLow  ("EURNOK",0,i); 
       GL[i][61]= iLow  ("EURSEK",0,i); 
       GL[i][62]= iLow  ("EURDKK",0,i); 
       GL[i][63]= iLow  ("EURNZD",0,i); 
       GL[i][64]= iLow  ("EURSGD",0,i); 
       GL[i][65]= iLow  ("EURHKD",0,i); 
       GL[i][66]= iLow  ("USDCHF",0,i); 
       GL[i][67]= iLow  ("USDJPY",0,i); 
       GL[i][68]= iLow  ("USDCAD",0,i); 
       GL[i][69]= iLow  ("USDNOK",0,i); 
       GL[i][70]= iLow  ("USDSEK",0,i); 
       GL[i][71]= iLow  ("USDDKK",0,i); 
       GL[i][72]= iLow  ("USDSGD",0,i); 
       GL[i][73]= iLow  ("USDHKD",0,i);
       GL[i][74]= iLow  ("USDMXN",0,i); 
       GL[i][75]= iLow  ("USDZAR",0,i); 
       GL[i][76]= iLow  ("GBPUSD",0,i); 
       GL[i][77]= iLow  ("AUDUSD",0,i); 
       GL[i][78]= iLow  ("NZDUSD",0,i); 
       GL[i][79]= GL[i][54]*GL[i][74];  //Low"EURMXN"
       GL[i][80]= GL[i][54]*GL[i][75];  //Low"EURZAR"                               
     }//2 

   for (j=0; j<27; j++)
     {//3
      Kf[j]=0;
    for (i=1; i<=LengthSample; i++)
      Kf[j]+=GL[i][j];
      Kf[j]/=LengthSample;
     }//3 
       
      CloseOch   = (GL[LengthSample][0]/Kf[0])*((Kf[0]/GL[LengthSample][0]+GL[LengthSample][12]/Kf[12]+GL[LengthSample][13]/Kf[13]
                   +GL[LengthSample][14]/Kf[14]+GL[LengthSample][15]/Kf[15]+GL[LengthSample][16]/Kf[16]+GL[LengthSample][17]/Kf[17]
                   +GL[LengthSample][18]/Kf[18]+GL[LengthSample][19]/Kf[19]+GL[LengthSample][20]/Kf[20]+GL[LengthSample][21]/Kf[21]
                   +Kf[22]/GL[LengthSample][22]+Kf[23]/GL[LengthSample][23]
                   +Kf[24]/GL[LengthSample][24])/14)/((GL[LengthSample][0]/Kf[0]
                   +GL[LengthSample][1]/Kf[1]+GL[LengthSample][2]/Kf[2]+GL[LengthSample][3]/Kf[3]+GL[LengthSample][4]/Kf[4]
                   +GL[LengthSample][5]/Kf[5]+GL[LengthSample][6]/Kf[6]+GL[LengthSample][7]/Kf[7]+GL[LengthSample][8]/Kf[8]
                   +GL[LengthSample][9]/Kf[9]+GL[LengthSample][10]/Kf[10]+GL[LengthSample][11]/Kf[11]+GL[LengthSample][25]/Kf[25]
                   +GL[LengthSample][26]/Kf[26])/14); 

      HighOch    = (GL[LengthSample][27]/Kf[0])*((Kf[0]/GL[LengthSample][27]+GL[LengthSample][39]/Kf[12]+GL[LengthSample][40]/Kf[13]
                   +GL[LengthSample][41]/Kf[14]+GL[LengthSample][42]/Kf[15]+GL[LengthSample][43]/Kf[16]+GL[LengthSample][44]/Kf[17]
                   +GL[LengthSample][45]/Kf[18]+GL[LengthSample][46]/Kf[19]+GL[LengthSample][47]/Kf[20]+GL[LengthSample][48]/Kf[21]
                   +Kf[22]/GL[LengthSample][49]+Kf[23]/GL[LengthSample][50]
                   +Kf[24]/GL[LengthSample][51])/14)/((GL[LengthSample][27]/Kf[0]
                   +GL[LengthSample][28]/Kf[1]+GL[LengthSample][29]/Kf[2]+GL[LengthSample][30]/Kf[3]+GL[LengthSample][31]/Kf[4]
                   +GL[LengthSample][32]/Kf[5]+GL[LengthSample][33]/Kf[6]+GL[LengthSample][34]/Kf[7]+GL[LengthSample][35]/Kf[8]
                   +GL[LengthSample][36]/Kf[9]+GL[LengthSample][37]/Kf[10]+GL[LengthSample][38]/Kf[11]+GL[LengthSample][52]/Kf[25]
                   +GL[LengthSample][53]/Kf[26])/14);
      
      LowOch     = (GL[LengthSample][54]/Kf[0])*((Kf[0]/GL[LengthSample][54]+GL[LengthSample][66]/Kf[12]+GL[LengthSample][67]/Kf[13]
                   +GL[LengthSample][68]/Kf[14]+GL[LengthSample][69]/Kf[15]+GL[LengthSample][70]/Kf[16]+GL[LengthSample][71]/Kf[17]
                   +GL[LengthSample][72]/Kf[18]+GL[LengthSample][73]/Kf[19]+GL[LengthSample][74]/Kf[20]+GL[LengthSample][75]/Kf[21]
                   +Kf[22]/GL[LengthSample][76]+Kf[23]/GL[LengthSample][77]+Kf[24]/GL[LengthSample][78])/14)/((GL[LengthSample][54]/Kf[0]
                   +GL[LengthSample][55]/Kf[1]+GL[LengthSample][56]/Kf[2]+GL[LengthSample][57]/Kf[3]+GL[LengthSample][58]/Kf[4]
                   +GL[LengthSample][59]/Kf[5]+GL[LengthSample][60]/Kf[6]+GL[LengthSample][61]/Kf[7]+GL[LengthSample][62]/Kf[8]
                   +GL[LengthSample][63]/Kf[9]+GL[LengthSample][64]/Kf[10]+GL[LengthSample][65]/Kf[11]+GL[LengthSample][79]/Kf[25]
                   +GL[LengthSample][80]/Kf[26])/14);
      
   for (i=LengthSample-1; i>=0; i--)
     {//4
      EURUSDClose[i]= GL[i][0]/Kf[0];

      EURClose[i]= (GL[i][0]/Kf[0]+GL[i][1]/Kf[1]+GL[i][2]/Kf[2]+GL[i][3]/Kf[3]+GL[i][4]/Kf[4]+GL[i][5]/Kf[5]+GL[i][6]/Kf[6]
                   +GL[i][7]/Kf[7]+GL[i][8]/Kf[8]+GL[i][9]/Kf[9]+GL[i][10]/Kf[10]+GL[i][11]/Kf[11]+GL[i][25]/Kf[25]
                   +GL[i][26]/Kf[26]+CloseOch)/14; 
                   
      USDClose[i]= (Kf[0]/GL[i][0]+GL[i][12]/Kf[12]+GL[i][13]/Kf[13]+GL[i][14]/Kf[14]+GL[i][15]/Kf[15]+GL[i][16]/Kf[16]
                   +GL[i][17]/Kf[17]+GL[i][18]/Kf[18]+GL[i][19]/Kf[19]+GL[i][20]/Kf[20]+GL[i][21]/Kf[21]+Kf[22]/GL[i][22]
                   +Kf[23]/GL[i][23]+Kf[24]/GL[i][24]+CloseOch)/14;
      
      CloseOch   = EURUSDClose[i]*USDClose[i]/EURClose[i];      
      GBPClose[i]= (Kf[1]*EURClose[i]/GL[i][1]+GL[i][22]*USDClose[i]/Kf[22])/2;                                                                 
      JPYClose[i]= (Kf[2]*EURClose[i]/GL[i][2]+Kf[13]*USDClose[i]/GL[i][13])/2;       
      AUDClose[i]= (Kf[3]*EURClose[i]/GL[i][3]+GL[i][23]*USDClose[i]/Kf[23])/2;       
      CHFClose[i]= (Kf[4]*EURClose[i]/GL[i][4]+Kf[12]*USDClose[i]/GL[i][12])/2;      
      CADClose[i]= (Kf[5]*EURClose[i]/GL[i][5]+Kf[14]*USDClose[i]/GL[i][14])/2;      
      NOKClose[i]= (Kf[6]*EURClose[i]/GL[i][6]+Kf[15]*USDClose[i]/GL[i][15])/2;      
      SEKClose[i]= (Kf[7]*EURClose[i]/GL[i][7]+Kf[16]*USDClose[i]/GL[i][16])/2;      
      DKKClose[i]= (Kf[8]*EURClose[i]/GL[i][8]+Kf[17]*USDClose[i]/GL[i][17])/2;      
      NZDClose[i]= (Kf[9]*EURClose[i]/GL[i][9]+GL[i][24]*USDClose[i]/Kf[24])/2;      
      SGDClose[i]= (Kf[10]*EURClose[i]/GL[i][10]+Kf[18]*USDClose[i]/GL[i][18])/2;      
      HKDClose[i]= (Kf[11]*EURClose[i]/GL[i][11]+Kf[19]*USDClose[i]/GL[i][19])/2;      
      MXNClose[i]= (Kf[25]*EURClose[i]/GL[i][25]+Kf[20]*USDClose[i]/GL[i][20])/2;      
      ZARClose[i]= (Kf[26]*EURClose[i]/GL[i][26]+Kf[21]*USDClose[i]/GL[i][21])/2;      
      EURUSDHigh[i] = GL[i][27]/Kf[0];                   
      EURHigh[i] = (GL[i][27]/Kf[0]+GL[i][28]/Kf[1]+GL[i][29]/Kf[2]+GL[i][30]/Kf[3]+GL[i][31]/Kf[4]+GL[i][32]/Kf[5]
                   +GL[i][33]/Kf[6]+GL[i][34]/Kf[7]+GL[i][35]/Kf[8]+GL[i][36]/Kf[9]+GL[i][37]/Kf[10]+GL[i][38]/Kf[11]
                   +GL[i][52]/Kf[25]+GL[i][53]/Kf[26]+HighOch)/14; 
                 
      USDHigh[i] = (Kf[0]/GL[i][27]+GL[i][39]/Kf[12]+GL[i][40]/Kf[13]+GL[i][41]/Kf[14]+GL[i][42]/Kf[15]+GL[i][43]/Kf[16]
                   +GL[i][44]/Kf[17]+GL[i][45]/Kf[18]+GL[i][46]/Kf[19]+GL[i][47]/Kf[20]+GL[i][48]/Kf[21]+Kf[22]/GL[i][49]
                   +Kf[23]/GL[i][50]+Kf[24]/GL[i][51]+HighOch)/14;             
      
      HighOch    = EURUSDHigh[i]*USDHigh[i]/EURHigh[i];      
      GBPHigh[i] = (Kf[1]*EURHigh[i]/GL[i][28]+GL[i][49]*USDHigh[i]/Kf[22])/2;                                                                 
      JPYHigh[i] = (Kf[2]*EURHigh[i]/GL[i][29]+Kf[13]*USDHigh[i]/GL[i][40])/2;       
      AUDHigh[i] = (Kf[3]*EURHigh[i]/GL[i][30]+GL[i][50]*USDHigh[i]/Kf[23])/2;       
      CHFHigh[i] = (Kf[4]*EURHigh[i]/GL[i][31]+Kf[12]*USDHigh[i]/GL[i][39])/2;      
      CADHigh[i] = (Kf[5]*EURHigh[i]/GL[i][32]+Kf[14]*USDHigh[i]/GL[i][41])/2;      
      NOKHigh[i] = (Kf[6]*EURHigh[i]/GL[i][33]+Kf[15]*USDHigh[i]/GL[i][42])/2;      
      SEKHigh[i] = (Kf[7]*EURHigh[i]/GL[i][34]+Kf[16]*USDHigh[i]/GL[i][43])/2;      
      DKKHigh[i] = (Kf[8]*EURHigh[i]/GL[i][35]+Kf[17]*USDHigh[i]/GL[i][44])/2;      
      NZDHigh[i] = (Kf[9]*EURHigh[i]/GL[i][36]+GL[i][51]*USDHigh[i]/Kf[24])/2;      
      SGDHigh[i] = (Kf[10]*EURHigh[i]/GL[i][37]+Kf[18]*USDHigh[i]/GL[i][45])/2;      
      HKDHigh[i] = (Kf[11]*EURHigh[i]/GL[i][38]+Kf[19]*USDHigh[i]/GL[i][46])/2;      
      MXNHigh[i] = (Kf[25]*EURHigh[i]/GL[i][52]+Kf[20]*USDHigh[i]/GL[i][47])/2;      
      ZARHigh[i] = (Kf[26]*EURHigh[i]/GL[i][53]+Kf[21]*USDHigh[i]/GL[i][48])/2;
            
      EURUSDLow[i]  = GL[i][54]/Kf[0];      
      EURLow[i]  = (GL[i][54]/Kf[0]+GL[i][55]/Kf[1]+GL[i][56]/Kf[2]+GL[i][57]/Kf[3]+GL[i][58]/Kf[4]+GL[i][59]/Kf[5]
                   +GL[i][60]/Kf[6]+GL[i][61]/Kf[7]+GL[i][62]/Kf[8]+GL[i][63]/Kf[9]+GL[i][64]/Kf[10]+GL[i][65]/Kf[11]
                   +GL[i][79]/Kf[25]+GL[i][80]/Kf[26]+LowOch)/14; 
                   
      USDLow[i]  = (Kf[0]/GL[i][54]+GL[i][66]/Kf[12]+GL[i][67]/Kf[13]+GL[i][68]/Kf[14]+GL[i][69]/Kf[15]+GL[i][70]/Kf[16]
                   +GL[i][71]/Kf[17]+GL[i][72]/Kf[18]+GL[i][73]/Kf[19]+GL[i][74]/Kf[20]+GL[i][75]/Kf[21]+Kf[22]/GL[i][76]
                   +Kf[23]/GL[i][77]+Kf[24]/GL[i][78]+LowOch)/14;
      
      LowOch     = EURUSDLow[i]*USDLow[i]/EURLow[i];      
      GBPLow[i]  = (Kf[1]*EURLow[i]/GL[i][55]+GL[i][76]*USDLow[i]/Kf[22])/2;                                                                 
      JPYLow[i]  = (Kf[2]*EURLow[i]/GL[i][56]+Kf[13]*USDLow[i]/GL[i][67])/2;       
      AUDLow[i]  = (Kf[3]*EURLow[i]/GL[i][57]+GL[i][77]*USDLow[i]/Kf[23])/2;       
      CHFLow[i]  = (Kf[4]*EURLow[i]/GL[i][58]+Kf[12]*USDLow[i]/GL[i][66])/2;      
      CADLow[i]  = (Kf[5]*EURLow[i]/GL[i][59]+Kf[14]*USDLow[i]/GL[i][68])/2;      
      NOKLow[i]  = (Kf[6]*EURLow[i]/GL[i][60]+Kf[15]*USDLow[i]/GL[i][69])/2;      
      SEKLow[i]  = (Kf[7]*EURLow[i]/GL[i][61]+Kf[16]*USDLow[i]/GL[i][70])/2;      
      DKKLow[i]  = (Kf[8]*EURLow[i]/GL[i][62]+Kf[17]*USDLow[i]/GL[i][71])/2;      
      NZDLow[i]  = (Kf[9]*EURLow[i]/GL[i][63]+GL[i][78]*USDLow[i]/Kf[24])/2;      
      SGDLow[i]  = (Kf[10]*EURLow[i]/GL[i][64]+Kf[18]*USDLow[i]/GL[i][72])/2;      
      HKDLow[i]  = (Kf[11]*EURLow[i]/GL[i][65]+Kf[19]*USDLow[i]/GL[i][73])/2;      
      MXNLow[i]  = (Kf[25]*EURLow[i]/GL[i][79]+Kf[20]*USDLow[i]/GL[i][74])/2;      
      ZARLow[i]  = (Kf[26]*EURLow[i]/GL[i][80]+Kf[21]*USDLow[i]/GL[i][75])/2;      
     }//4  

   return(0);

     }//1
//+------------------------------------------------------------------+

For the correct operation of the terminal, all currency pairs used in it should be downloaded with the same timeframe.

In the loop limited by "//2", data is downloaded from all securities used by the indicator with the help of three functions: iClose, iHigh, iLow. In the loop limited by "//3" scaling ratios for all symbols is calculated. Further compensating error on the LengthSample bar is calculated. In the loop limited by "//4" all national currencies are calculated according to the above algorithm as well as the compensating error on this bar is calculated.

If it is necessary to represent calculated data not in a separate window, but to show them in the main chart window, the calculated currency values should be multiplied by the scaling ratio obtained from EURUSD; besides, #property indicator_separate_window should be replaced by #property indicator_chart_window. Fig. 6 shows the result of such a calculation. EUR – pink, USD – blue, GBP – red, JPY – brown, AUD – purple, CHF – yellow, CAD – black.

Fig.6



Conclusion

The represented method for the calculation of national currencies is universal and can be similarly used for other symbols. Besides, it allows synthesizing currency pairs that are not represented in your brokerage company, or get some exotic pairs that do not exist at all. All this, together with the extraction of national currencies from currency pairs will increase the informative character of symbols that you utilize helping to conduct more accurate estimation of market conditions and building various efficient trading strategies.

Translated from Russian by MetaQuotes Ltd.
Original article: https://www.mql5.com/ru/articles/1570

Attached files |
SuperPosition.mq4 (17.57 KB)
Last comments | Go to discussion (18)
[Deleted] | 5 Jun 2009 at 15:52
Hi - excellent work. I had never thought of using synthetic pairs as well as real ones to calculate currency values. Just wondering if at least part of the error that you have to compensate for is due to a too simple formula for the synthetic pairs. Sometimes need to calculate using the Ask value for the pair, see this article "http://www.futurestech.com.au/Thoughts.htm#Synthetic Pairs"
[Deleted] | 5 Jun 2009 at 18:14

hi i dont have any question,i just share what i did befor

thanks

majid

Andrea Bronzini
Andrea Bronzini | 16 Jun 2009 at 22:43
Fabio:

Hi Andrea

I made some progress, I re-coded the indicator, but I think I made some error because I do not obtain the right value for EURUSD close.

Have a look and may be improve it ;-)

Cheers

Fabio


Ciao Fabio,
did you manage to make it work??? ...it seems I have problems with MT4 using simultaneously history from different pairs :(
Maybe if you write me in private we can sort it out: http://www.mql4.com/users/Zypkin


Andrea

[Deleted] | 22 Jun 2009 at 19:21
This indicator does not work :):):)
Khristian Piligrim
Khristian Piligrim | 30 Jun 2009 at 18:40
I finish my activity in the Forex market and I will not appear in this forum any more. Therefore I will not be able to answer your questions. Please find more details in the topic Piligrimus - neuronet indicator (in Russian.'
Who does not know Russian, can take advantage of the electronic translator of sites http://www.online-translator.com/site_translation.aspx?prmtlang=en
In the specified theme you can download my indicators free of charge.
Interaction between MеtaTrader 4 and MATLAB Engine (Virtual MATLAB Machine) Interaction between MеtaTrader 4 and MATLAB Engine (Virtual MATLAB Machine)
The article contains considerations regarding creation of a DLL library - wrapper that will enable the interaction of MetaTrader 4 and the MATLAB mathematical desktop package. It describes "pitfalls" and ways to overcome them. The article is intended for prepared C/C++ programmers that use the Borland C++ Builder 6 compiler.
On the Long Way to Be a Successful Trader - The Two Very First Steps On the Long Way to Be a Successful Trader - The Two Very First Steps
The main point of this article is to show a practical way to implement an effective MM. This can be achieved only by using a certain kind of strategies that we need to identify and describe first. In the following we’ll cover the basic concepts of how to build such a strategy and we’ll point out the common mistakes which always end up in draining a trader’s account.
Working with Doubles in MQL4 Working with Doubles in MQL4
In this note we will consider a typical programming errors, that occurs while working with double numbers in MQL4 programs.
Using Neural Networks In MetaTrader Using Neural Networks In MetaTrader
This article shows you how to easily use Neural Networks in your MQL4 code taking advantage of best freely available artificial neural network library (FANN) employing multiple neural networks in your code.