Hi guys
I am trying to find a way to programmatically re-initialise all of the active charts.
What I tried is to write a loop that goes through all the active charts and change the TF to M1 and back to its previous TF.
void InitialiseActiveCharts()
{
long currChart,prevChart=ChartFirst();
int i=0,limit=10000;
while(i<limit)// We have certainly not more than 100 open charts
{
currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID
if(currChart<0) break; // Have reached the end of the chart list
prevChart=currChart;// let's save the current chart ID for the ChartNext()
i++;// Do not forget to increase the counter
int period= ChartPeriod(currChart); // save the chart period
string symbol= ChartSymbol(currChart); // save the chart symbol
ChartSetSymbolPeriod(currChart,symbol,1); // change to M1
ChartSetSymbolPeriod(currChart,symbol,period); // apply the previous TF
}
}
The problem with the above function is that the “period” that was meant to save the initial TimeFrame of the chart gets lost and does not proceed.
Also changing the TF could disturb the smooth operation of the EA.
Does anyone have any suggestion of how to achieve that?
The reason is the following.
I have several charts running the same EA with a function in the init() part that reads a file.
I only need to read the file on the initialization.
The file gets populated based on another EA (Master EA) that runs on another chart. Whenever this master EA gets initialized the file gets updated
and therefore I need the other charts to re-initialize so they can read the new values.