symbol changer affects 1st chart time frame

 

Good day,
I am writing a script for changing all the chart with the same symbol. All is ok BUT...

if I drag and Drop the script not on the 1st terminal chart,
the script change the 1st terminal chart timeframe, with the timeframe of the chart where it was dragged and dropped...why ?
Can you gelp me to fix it please ?

Regards.

long  chart_actual;                                                             
long  chart_previous = ChartFirst();                                           
int   count = 0;                                                             
ChartSetSymbolPeriod(chart_previous, symbol_to_change, 0);                    
//---
/*
int   limit   = 10;                                                            
while (count < limit)                                                    
*/
while (chart_previous != -1)                                                   
{
  chart_actual = ChartNext(chart_previous);                                    
  //---
  ENUM_TIMEFRAMES chart_actual_tf_enum = ChartPeriod(chart_actual);             
  ChartSetSymbolPeriod(chart_actual, symbol_to_change, chart_actual_tf_enum);  
  chart_previous = chart_actual;                                              
  count++;                                                                         
}
 
Email Temporaire: if I drag and Drop the script not on the 1st terminal chart,
long  chart_previous = ChartFirst();                                           
⋮  chart_actual = ChartNext(chart_previous);                                    
 ⋮
  chart_previous = chart_actual;   

You never process ChartFirst.

Reason: