Kindly assist me in EA creating issue ( Periodically change chart)

 
Hello everyone, recently I have built an MT5 expert advisor about constantly changing the chart of a single window periodically (Like 5s/time changing).

Recently a client has told me that it possesses a "flickering" problem when trying to use the EA. But the same problem doesn't exist on my PC.

I think the problem is on this part:

void OnTimer()
{
   if(!isRunning) return;
   
   static int i = 0;
   ChartSetSymbolPeriod(0, Symbols[i], PERIOD_CURRENT);
   i = (i + 1) % ArraySize(Symbols);
}

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
   if(id == CHARTEVENT_OBJECT_CLICK)
   {
      if(sparam == "PauseButton")
      {
         isRunning = !isRunning; // Toggle the running state
      }
   }
}

Can anyone tell me what seems to be the problem causing a chart flickering? Thanks !

Chart flickering : https://www.youtube.com/watch?v=x2YXs-qvLTM

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

Every time your EA changes symbol/TF it resets (as if you changed them manually), possibly the timer gets executed right after setting it (and then every 5s) and it causes flickering.

Personally I would save the datetime in OnInit, set a faster timer (depending on the precision you need, 1s or some milliseconds) and check the current datetime minus the initial one (CurrentTime, or TickCount or MicrosecondCount depending also on the precision needed)