MT5 Build 1966: Error copying rates from different timeframes

 

Hello,


My terminal was upgraded to version 1966, and I've noticed a problem when I attach an EA to a graph related to the copy of MqlRates from other timeframes.

For example, an EA runs on M6 timeframe, but at initialization it checks some rates from D1, and in this case the function CopyRates returns the error 4401 - History not found (although all the history needed is available).

After that error, the graph gets freezed (cannot scroll anymore) and if I try to open another chart for that symbol with the same timeframe (M6) or D1 I get only a big "Waiting For Update" and the chart never loads. All the other timeframes load correctly.

Those EAs are running fine on terminal build 1940.

Is there any change related to the access of rates from other timeframes that I have to care about? I can't find any release notes for this build.


Thank you.

 
Antonio Guglielmi: All the other timeframes load correctly.

Possible Solution,

try remove the ea
restart your computer and Internet
for the fact order time frame work, try another broker

 

 

Hi Samuel,


I've done that many times with no luck. And I've heard from other users that they're having the same issue.

It's happening even with the MetaQuotes-Demo server.


Thank you.

 
Antonio Guglielmi:

Hi Samuel,


I've done that many times with no luck. And I've heard from other users that they're having the same issue.

It's happening even with the MetaQuotes-Demo server.


Thank you.

Build 1966 is a beta version, don't connect to Metaquotes-Demo server if you don't want to be a beta tester.

Last beta is 1970, try it if you want.

 
Alain Verleyen:

Build 1966 is a beta version, don't connect to Metaquotes-Demo server if you don't want to be a beta tester.

Last beta is 1970, try it if you want.

Hi Alain,

Yes, I'll have to avoid it.

Anyway, after many tests, I found the function which was causing me trouble: ChartSetSymbolPeriod()

For some reason, after calling that function the graph crashes.

It's possible to reproduce the problem with this simple code:

int OnInit()
  {
//---
      MqlRates dailyRates[];
      datetime times[];  

      // Function with issue....
      ChartSetSymbolPeriod(0, _Symbol, _Period);      
  
  
      if (CopyRates(_Symbol, PERIOD_D1, 0, 10, dailyRates) < 0) {
         Print ("Error copying rates: ", GetLastError());
      }

      if (CopyTime(_Symbol, PERIOD_D1, 0, 10, times) < 0) {
         Print ("Error copying rates: ", GetLastError());
      }

      Print("Bars :",  Bars(_Symbol, _Period));
      Print("Daily bars :",  Bars(_Symbol, PERIOD_D1));
      
      
      
      Print("Yesterday close: ", dailyRates[1].close);

  
//---
   return(INIT_SUCCEEDED);
  }


I'm moving back to the last stable version.

Thank you!

 
Antonio Guglielmi:

Hi Alain,

Yes, I'll have to avoid it.

Anyway, after many tests, I found the function which was causing me trouble: ChartSetSymbolPeriod()

For some reason, after calling that function the graph crashes.

It's possible to reproduce the problem with this simple code:


I'm moving back to the last stable version.

Thank you!

Why using ChartSetSymbolPeriod() in OnInit() ?

Also getting data in OnInit() is not a good idea unless you had code to be sure data are ready.

 
Alain Verleyen:

Why using ChartSetSymbolPeriod() in OnInit() ?

Also getting data in OnInit() is not a good idea unless you had code to be sure data are ready.


I use the function as kind of a protection, in some specific cases. My EAs have an input parameter to define the desired timeframe. The default value is always PERIOD_CURRENT, which means to use the chart's period, but the user can specify the desired timeframe. In that case, if at OnInit() the EA detects that the chart is in a different timeframe it automaticaly switches to the correct one. The parameter and function are also useful within the Strategy Tester to check the strategy performance through multiple timeframes during optimization.

Regarding the data, the EA gathers only some time values in order to detect new bars and change of day when a new tick arrives.

Reason: