Download MetaTrader 5

Change text of an object on every second by OnTimer?

To add comments, please log in or register
Karish
138
Karish  

Hello,

A bit newbie question.., but how can i make a text of an object to change itself on every second for example:

 

text object #1 will be change every second like so:

"."

".."

"..."

"...."

"....."

and then back to "." and same loop again and again.., thank you guys!

Janek6191
29
Janek6191  
// where ProfitLabel is the object name
void OnTick(){
       
    ObjectSetString(chart_ID,"ProfitLabel",OBJPROP_TEXT,DoubleToStr(profit,2));
}
Karish
138
Karish  

sorry i edited the OnTick to OnTimer, please help, it support to be OnTimer...!

whroeder1
16098
whroeder1  
  1. OnTick or OnTimer is irrelevant. You must set the text. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. string text = "12345";
    string curr = ObjectGetString(chart_ID,"ProfitLabel",OBJPROP_TEXT);
    int    len  = (StringLen(curr) % StringLen(text)) + 1;              // 1->2->3->4->5->1
    string next = StringSubstr(text, 0, len);                           // "1","12"...
    ObjectSetString(chart_ID,"ProfitLabel",OBJPROP_TEXT, next);

Karish
138
Karish  

@WHRoeder, thank you for your help, i understand, but the function "OnTimer()" is new for me..,

 

i'm just trying to make a simple text change every 1 second.., like so for example:

"."

".."

"..."

"...."

"....."

and then the text will return to the first text in a loop and so on every 1 second... 

 

please help..., thank you..! 

Keith Watford
Moderator
10614
Keith Watford  
   static string text=".";
   if(text=="......")
      text=".";
   //Set the text in the object
   text+=".";

.

Karish
138
Karish  
Thanks!!
To add comments, please log in or register