CHARTEVENT_OBJECT_CREATE and endless loop

 

hi

i used CHARTEVENT_OBJECT_CREATE to change color and the name of every trend line user draw on chart

and i used a Counter to add number to a origin  name and put it on trend line

but it's cause a endless loop and Counter don't stop Counting

Files:
test001.mq4  3 kb
 
Masoud42mt4:

hi

i used CHARTEVENT_OBJECT_CREATE to change color and the name of every trend line user draw on chart

and i used a Counter to add number to a origin  name and put it on trend line

but it's cause a endless loop and Counter don't stop Counting

You can do something like this to avoid endless looping:

   string namePrefix = "ROB_TREND";
   if(id==CHARTEVENT_OBJECT_CREATE && StringFind(sparam,namePrefix)<0 && ObjectType(sparam)==OBJ_TREND)
     {
      ObjectSetString(0,sparam,OBJPROP_NAME,namePrefix+(string)numtr);
      ObjectSetInteger(0,namePrefix+(string)numtr,OBJPROP_COLOR,clrBlue);
      Comment(numtr);
      numtr++;
     }
 
Seng Joo Thio:

You can do something like this to avoid endless looping:

thanks

the problem solved

but  i want name them like A1,A2,A3,...

but the number is going significantly large and then counting stopped

how i can just set one iteration per CHART_EVENT?

 
If the object is correct, don't modify it again.
You Server
Change the SL to X It is at X!
Change the SL to X It is at X!
Change the SL to X You are insane
Insanity: doing the same thing over and over again and expecting different results.
          Unknown
 
Masoud42mt4:

thanks

the problem solved

but  i want name them like A1,A2,A3,...

but the number is going significantly large and then counting stopped

how i can just set one iteration per CHART_EVENT?

I don't understand your question, because the number only increase once based on my suggestion above... show your latest code if you're still having issues...