Multi-Currency synchronization

 

Here some tests results and below details:

 

 

Code used:

// chart symbol is GBPUSD
// ETimeFrame is PERIOD_H1
// LCrtTime is a datetime

void OnTick()
{
   CopyTime(Symbol(),ETimeFrame,0,1,LCkSigTime);
   LCrtTime = LCkSigTime[0];   
      
   datetime aTimeTmp[1];
   CopyTime("GBPUSD",ETimeFrame,1,1,aTimeTmp);
   datetime aGBPUSD = aTimeTmp[0];
   
   CopyTime("GBPJPY",ETimeFrame,1,1,aTimeTmp);
   datetime aGBPJPY = aTimeTmp[0];
      
   CopyTime("USDJPY",ETimeFrame,1,1,aTimeTmp);
   datetime aUSDJPY = aTimeTmp[0];      
   
   CopyTime("GBPCHF",ETimeFrame,1,1,aTimeTmp);
   datetime aGBPCHF = aTimeTmp[0];
      
   CopyTime("USDCHF",ETimeFrame,1,1,aTimeTmp);
   datetime aUSDCHF = aTimeTmp[0];
            
      int aFH = FileOpen("res.csv",FILE_READ|FILE_WRITE|FILE_CSV);
      if(aFH != INVALID_HANDLE)
      {
         FileSeek(aFH,0,SEEK_END);
         FileWrite(aFH,LCrtTime,aGBPUSD,aGBPJPY,aUSDJPY,aGBPCHF,aUSDCHF);
         FileClose(aFH);
      }
      else
         Print("INVALID FILE H",GetLastError());     
           
}

I tested using H1, Open prices only, GBPUSD chart; 

As  in image , the bar times are not the same for different pairs at the same shift 1 (one bar back) for most of the tick generation.

Sometimes the bar times matches, as in the last record in image.

My question is, shouldnt the bar time be the same time at same shift for different pairs ?

I suppose this is happening with M5, M15 or other timeframes even when we use Every Tick ?

This suggests me the bars series are not synched on different pairs so we can not have indicators using multi-currencies like in this article ?: https://www.mql5.com/en/articles/83 

Do I do somethingh wrong ?

Attached the xls files and captures 

Files:
bars_sync.zip  46 kb
 

Coming back, some more concrete results regarding above post. I run a test ea.

Below is the bad ea results when using the  bars series as they are in MT5

 

If I insert in my EA this code (eplained in prev post above) which checks the bars synchronization on multiple pairs and skip the ticks when the bars have not the same time:

   if(!(LCrtTime == aGBPCHF && LCrtTime == aGBPJPY && LCrtTime == aUSDJPY && LCrtTime == aUSDCHF))
      return;  // from OnTick, skip current bar

then the results of the same EA is

 

Pretty explanatory that something is wrong with the bars on different currencies.

My EA only needs the current bar to do some calculations so synching the bars on different pairs used have proven much better results as above.

It appears obviously for indicators which uses periods/bars back trying to calculate some data on multiple currencies, they will be wrong and so the EA results.

thank you 

 

This bug is serious, because it's somewhere in the deepest mechanics of the tester. If the synchronization is faulty, multiasset backtesting is a joke - so this thing has to be sorted out.

In MT4 times, cracks within history were to be accepted, of course, in older bar data. But this is not the time for rebates from quality.

 

The discussion here is clearly related to the problems described in the thread: https://www.mql5.com/en/forum/1972

Forcing synchronization by skipping ticks is the only attempt to work around, but is of course not a solution.

Do you have any new observations on this? 

Are you still attempting to create a multi-pair EA? 

 

Kinda left them a while. I have in progress a multicurrency EA that is not made to trade (it's made to calculate and write). Also, OnTrade() is blasted also on backtester: https://www.mql5.com/en/forum/1926

I didn't get into studying how OnBookEvent works, hopefully at least that works correctly even if the backtester has issues. 

The messy OnTrade() on Strategy Tester
  • www.mql5.com
Selected deal ticket 1 having entry 0 in the HistorySelect queueHN 0 OnTradeStressTest (EURUSD,M1) 12:29:55 2010.
 

im noticing there is always new version for terminal but why metaquote don't fix these problem yet ? how would ATC2010 still gonna start soon ? it's very useless cuz all sort of bug in tester and result will not accurate any more..


 :( ..sign


 

I'm sure that if they know about it they try hard to fix it. I assume that they know about it. Notice that there is nowhere around a textbook example of a multicurrency EA. Guess why? 

Anyways, the metatrader5 show must go on and the championship will start on time in a lottery fasion. Contestants will submit whatever they have and there will be a random winner with a random performance.


 

 
trendick:

The discussion here is clearly related to the problems described in the thread: https://www.mql5.com/en/forum/1972

Forcing synchronization by skipping ticks is the only attempt to work around, but is of course not a solution.

Do you have any new observations on this? 

Are you still attempting to create a multi-pair EA? 

Hi,

I have also initiated similar problem here https://www.mql5.com/en/forum/1642 and in many other similar posts.

It seems I still have to cry for them to be solved by MT5 team.

And, yes, still attempt to create multi-pair EA, you know ... Keep trying ... (on my time & money of course, who cares ? the mt5 bugs are not so important ...)

Tick generation - Open bar only
  • www.mql5.com
The whole list printed shows also many discrepancies in times.
 

Tektronic and TheEconmist,

Here is a simple approximate solution for synchronizing backtests of multi-currency EAs. EA is attached to the chart of Pair number 0 (among N), which is set to a fast time frame (M1). Variable TimeFrame is your desired time frame (say H1). Notice that the first call to CopyTime is with TimeFrame and the others are with Period().

If you run this you will get deviations of up to 1 minute in your price readings. If your time frame is high, like H1, it will approximate a correct run. Certainly not perfect,  but for some EAs will allow for reasonable testing.

If you already have better/other solutions, please let me know. Otherwise, how are you doing in your multicurrency EA development?

Regards,

- trendick 


void OnTick()
{
   int i;
   datetime dta[1];
   static datetime LastBarTime;

   // pair 0 (among N) is the "driver"
   CopyTime(Symbols[0],TimeFrame,0,1,dta);
   if (dta[0] != LastBarTime) {
      RoundNum++;
      Print("Debug --- Round ",RoundNum);
      LastBarTime = dta[0];
      for (i=0; i<N; i++) {
         CopyTime(Symbols[i],Period(),0,1,dta);
         Print("Debug --- Symbol ",Symbols[i]," : Time ",dta[0]);
      }
      
      // Do your stuff here. 
      Process();
   }
}
 

many thanksssss...