Displaying Comments in Color

 

I want to display some of my comments on the terminal in color, but I'm not finding any examples.

Could someone point me to one?

Thanks,

Bill

 
ObjectCreate("FlexiComment", OBJ_LABEL, ...);
 

Maybe I should have said a fully functional example, not just an unexplained code snipet.

Does any one know if there is a list of Text_Colors available?

Does MT4 use the fonts that are installed for other programs like Word or does it use it's own?

 
oneoleguy:

Maybe I should have said a fully functional example, not just an unexplained code snipet.

Irtron is implying that, to change colours or fonts, you need to create a text object on the chart rather than using Comment(). 


Partial - not entirely realistic - code sample as follows. You'd normally want to do an ObjectDelete() in deinit(), and either create the text object in init() or make sure that it doesn't already exist before potentially creating it on each call to start(). Text objects can't contain multi-line text - you need to create a separate object for each line instead - and they have a maximum width which can't be changed.


   string strMyObjectName = "My Text Object Name";

   string strMyObjectText = "Text to display in object";

   

   // Create text object with given name

   ObjectCreate(strMyObjectName, OBJ_LABEL, 0, 0, 0, 0);

   // Set pixel co-ordinates from top left corner (use OBJPROP_CORNER to set a different corner)

   ObjectSet(strMyObjectName, OBJPROP_XDISTANCE, 50);

   ObjectSet(strMyObjectName, OBJPROP_YDISTANCE, 50);

   // Set text, font, and colour for object

   ObjectSetText(strMyObjectName, strMyObjectText, 10, "Arial", CornflowerBlue);


 

Super and Thank you;

This is what I wrote:

===============================================

string HelloObjectName = "Hello";
string HelloObjectText = "Hello, World!";

// Create text object with given name

ObjectCreate(HelloObjectName, OBJ_LABEL, 0, 0, 0, 0);

// Set pixel co-ordinates from top left corner (use OBJPROP_CORNER to set a different corner)

ObjectSet(HelloObjectName, OBJPROP_XDISTANCE, 0);
ObjectSet(HelloObjectName, OBJPROP_YDISTANCE, 10);

// Set text, font, and colour for object

ObjectSetText(HelloObjectName, HelloObjectText, 10, "Arial", Red);
===============================================

O.K. How do I put pricing information on the screen at the end of this text?

Bill

 
jjc:

Irtron is implying that, to change colours or fonts, you need to create a text object on the chart rather than using Comment(). 


Thank you jjc, it was simple and good one, just wondering is it like Comment replace by last text?

i used this and only show last message

 string buytext = "My Text Object Name"; // Name of Object for color comment
   string Selltext = "My Text Object Name"; // Name of Object for color comment

   string strBuyText = "BUY ATR"; //String Const or Variable used on ObjectCreate
   string strSellText = "Sell ATR"; //String Const or Variable used on ObjectCreate

   

   // Create text object with given name

   ObjectCreate(buytext, OBJ_LABEL, 0, 0, 0, 0); // Type of Object Label = COMMENT OBJ_LABEL
   ObjectCreate(Selltext, OBJ_LABEL, 0, 0, 0, 0); // Type of Object Label = COMMENT OBJ_LABEL

   // Set pixel co-ordinates from top left corner (use OBJPROP_CORNER to set a different corner)

   ObjectSet(buytext, OBJPROP_XDISTANCE, 50);
   ObjectSet(buytext, OBJPROP_YDISTANCE, 50);
   
   ObjectSet(Selltext, OBJPROP_XDISTANCE, 20);
   ObjectSet(Selltext, OBJPROP_YDISTANCE, 70);   

   // Set text, font, and colour for object

   ObjectSetText(buytext, strBuyText, 10, "Arial", CornflowerBlue);
   ObjectSetText(Selltext, strSellText, 10, "Arial", clrRed);
   

 

Reason: