I'm trying to code a sript to change the current pairfor another.
I've found the way to change the chart where the script is running, but I can't get it running when I try to change the symbol in all the charts from one chart.
This is the code (revised):
Code: Select all
//+------------------------------------------------------------------+
//| changeSymbolAll.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property show_inputs
extern string symbolToChange = "AUDCAD";
extern bool changeAllWindows = false;
int start()
{
long currChart,prevChart=ChartFirst();
int i=0,limit=10;
if(changeAllWindows)
{
//Print("ChartFirst =",ChartSymbol(prevChart)," ID =",prevChart);
ChartSetSymbolPeriod(prevChart, symbolToChange, 0);
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
int period = ChartPeriod(currChart);
//Print(i,ChartSymbol(currChart)," ID =",currChart);
ChartSetSymbolPeriod(currChart, symbolToChange, period);
prevChart=currChart;// let's save the current chart ID for the ChartNext()
i++;// Do not forget to increase the counter
}
return(0);
}
else {ChartSetSymbolPeriod(prevChart, symbolToChange, 0);return(0);}
return(0);
}
Regards!!
Adrian.