ObjectSetText not working as expected

 

Hi folks,

I'm editing an indi that prints the previous sessions High & Low & plots them as horizontal trendlines, I'm trying to edit the text that is associated with each line.

The changes I make to the ObjectSetText line don't seem to have any bearing on the format of the text, wondering what I'm doing wrong?

Currently the text defaults in colour to the MT4 'foreground' colour, and strangely the text size is quite big (about 10-12). 

void drawTrendLine(string name, double time1, double time2, double price1, double price2, int thickness, color colour, int style, bool background, bool ray, string label = "") 
{
   if (ObjectFind(name) != 0) 
   {
      ObjectCreate(name, OBJ_TREND, 0, time1, price1, time2, price2);
      ObjectSet(name,OBJPROP_RAY,ray);
   
   } 
   else 
   {
      ObjectSet(name, OBJPROP_TIME1, time1);
      ObjectSet(name, OBJPROP_TIME2, time2);
      ObjectSet(name, OBJPROP_PRICE1, price1);
      ObjectSet(name, OBJPROP_PRICE2, price2);
   }

   ObjectSet(name,OBJPROP_COLOR, colour);
   ObjectSet(name,OBJPROP_WIDTH, thickness);
   ObjectSet(name,OBJPROP_BACK, background);
   ObjectSet(name,OBJPROP_STYLE, style);  
   ObjectSetText(name, label, 4, "Arial", DimGray);
}
 

From the ObjectSetText() documentation:

 

Note

For objects of OBJ_TEXT and OBJ_LABEL, this description is shown as a text line in the chart. Parameters of font_size, font_name and text_color are used for objects of OBJ_TEXT and OBJ_LABEL only. For objects of other types, these parameters are ignored.

 
drazen64:

From the ObjectSetText() documentation:

 

Note

For objects of OBJ_TEXT and OBJ_LABEL, this description is shown as a text line in the chart. Parameters of font_size, font_name and text_color are used for objects of OBJ_TEXT and OBJ_LABEL only. For objects of other types, these parameters are ignored.

 



Thanks Drazen, so would my solution be along the lines of ObjectCreate(name,OBJ_TEXT.... and then would ObjectSetText work?
 

Yes, besides trend line, put OBJ_TEXT or OBJ_LABEL and you will be able to change font and color of the text.