Deal with multiple objects mql5

 
Hey, Please, i coded and indicator and everything is okey and fine but it creates multiple objects and in the code i try to loop through them and it works fine. But if i load with other indicatos that themselves also creates multiple objects, the number of objects increase on the chart and when trying to modify them with by looping through them with the standard ObjectSetInteger() etc functions which are asynchronous, the objects then take time to refresh despite using ChartRedraw so for this issue where we have a large number of objects, what would be the best approach to modify them? Been looking for this on the forum but didn't found anything. Maybe I am wording it wrongly. Example of code of me looping throught the objects to modify them.

for(int i = ObjectsTotal(0) - 1; i >= 0; i--){
      
         string nameObj = ObjectName(0, i);
         if(StringFind(nameObj, Symbol()) != -1 && (StringFind(nameObj, prefix+" BUYZONE") != -1 || StringFind(nameObj, prefix+" SELLZONE") != -1)){
            
            ObjectSetInteger(0, nameObj, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);ChartRedraw(0);
         
         }
         if(StringFind(nameObj, Symbol()) == -1 && (StringFind(nameObj, prefix+" BUYZONE") != -1 || StringFind(nameObj, prefix+" SELLZONE") != -1)){
            
            ObjectSetInteger(0, nameObj, OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);ChartRedraw(0);
         
         }
         
      }
 
Bryan Djoufack Nguessong:
Hey, Please, i coded and indicator and everything is okey and fine but it creates multiple objects and in the code i try to loop through them and it works fine. But if i load with other indicatos that themselves also creates multiple objects, the number of objects increase on the chart and when trying to modify them with by looping through them with the standard ObjectSetInteger() etc functions which are asynchronous, the objects then take time to refresh despite using ChartRedraw so for this issue where we have a large number of objects, what would be the best approach to modify them? Been looking for this on the forum but didn't found anything. Maybe I am wording it wrongly. Example of code of me looping throught the objects to modify them.

En effet, puisque tu as plusieurs objets, il est déconseillé d'appeler la fonction "ObjetsTotal()" dans la boucle.

Deuxièmement, tu sembles répéter inutilement certaines opérations et fonctions.

Bref, essaie avec cette notation, tout simplement :

int Total = ObjectsTotal();
string symb = Symbol(), nameObj = "", strBuy = prefix + " BUYZONE", strSell = prefix+" SELLZONE";

for(int = 0; int < Total; i++)
 {
  nameObj = ObjectName(0, i);
  if (StringFind(nameObj, symb) != -1 && ((StringFind(nameObj, strBuy) != -1 || StringFind(nameObj, strSell) != -1)))  // Constatez que j'ai ajouter une paire de parenthèses pour cette deuxième partie de la condition
   {
    ObjectSetInteger(0, nameObj, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
   } 
 }
ChartRedraw(); // Appelez cette fonction une seule fois ici à la fin de toute la boucle, et non dans la boucle et à chaque itération, non.