MT5 - Force indicator refresh (like MT4)

 

Hello guys,

I want to know if there is a method on MT5 to force indicator refresh/reload without re-initailize them one by one.

I explain better: in MT4 if I copy a different version of an indicator in the Indicators\ folder, then on my platform, in Navigator panel I right click and do "Refresh" all changed indicators and EA already found on charts get reinitialized.

It does not happens on MT5 and I need to refresh manually (removing or changing a parameter) each indicator on chart in case of I upload a new version of an indicator.


I hope it's clear what I'm talking about.

Thanks to all!

 
Fabio Cavalloni:

You could write a simple script to loop through all the charts and set ChartSetSymbolPeriod().

From the documentation

ChartSetSymbolPeriod

Note

The symbol/period change leads to the re-initialization of the Expert Advisor attached to a chart.

The call of ChartSetSymbolPeriod with the same symbol and timeframe can be used to update the chart (similar to the terminal's Refresh command). In its turn, the chart update triggers re-calculation of the indicators attached to it. Thus, you are able to calculate an indicator on the chart even if there are no ticks (e.g., on weekends).



 
Interesting idea! Thanks
 

Unfortunately I had no success in doing it.

EA do not get reinitalized after my script run.

EA CODE:

int OnInit()
  {
   Print(__FUNCTION__);
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
   Print(__FUNCTION__);
  }

SCRIPT CODE:

void OnStart()
  {
   Print("Refresh chart script");
   long currChart=ChartFirst();
   int i=0,limit=100;
   while(i<limit)
     {
      if(currChart<0) break;
      if( !ChartSetSymbolPeriod(currChart,ChartSymbol(currChart),ChartPeriod(currChart)) ) Print("Error in refreshing chart "+(string)currChart);
      else Print("Chart "+(string)currChart+" refreshed!");
      currChart=ChartNext(currChart); 
      i++;
     }
   }

I get message that chart are reinitialized but no "OnInit" log is found on logs, so I expect that EA are not reainitalized. If I manually change timeframe I can see "OnDeinit" and "OnInit" logs correctly.


 

I did a lot of tests and I can conclude that, for some reasons, MT5 mantain on chart a "cached" version of the EA.

No matter if you reinitialize it. I tried also manually chaning timeframe but remain the old version until I manually remove it from chart and re attach it, or I restart platform.

(Still some problems with code I wrote and ChartSetSymbolPeriod() that do not trigger reinitialization but, I think that even if I will make it working with a script, that will not solve the "issue").

Once again, I miss MT4.

 
Fabio Cavalloni:

I did a lot of tests and I can conclude that, for some reasons, MT5 mantain on chart a "cached" version of the EA.

No matter if you reinitialize it. I tried also manually chaning timeframe but remain the old version until I manually remove it from chart and re attach it, or I restart platform.

(Still some problems with code I wrote and ChartSetSymbolPeriod() that do not trigger reinitialization but, I think that even if I will make it working with a script, that will not solve the "issue").

Once again, I miss MT4.

Hi Fabio,

Have you been able to resolve this issue in MT5?

 
i have this problem too
Reason: