Download MetaTrader 5

Text issues

To add comments, please log in or register
Share the links to products and make your profit
Paul Anscombe
3995
Paul Anscombe 2012.06.23 10:00 

I am struggling here, I want to place multiple lines of text on the chart without using the COMMENT command because that is always covered by the chart and is hard to read. But I have tried all of the different text objects and none of them seem to allow the carriage return \r or line feed \n characters to work.

So it seems that for all the different types of objects you can have none will allow you to create more than a single line of text per object which seems a bit crazy to me. Is there a way to do this?

 

thanks

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
onewithzachy
2271
onewithzachy 2012.06.23 12:57  
MaxTrader:

I am struggling here, I want to place multiple lines of text on the chart without using the COMMENT command because that is always covered by the chart and is hard to read. But I have tried all of the different text objects and none of them seem to allow the carriage return \r or line feed \n characters to work.

So it seems that for all the different types of objects you can have none will allow you to create more than a single line of text per object which seems a bit crazy to me. Is there a way to do this?

thanks

Hi MaxTrader,

How's your weekend ?,

This is a script, and enjoy the weekend

:D

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

void OnStart()
  {
//---
  CREATE_TEXT_LABEL ("Hi", 10, 10, "Terminal", 15, clrLime);
  CREATE_TEXT_LABEL ("Your Acc Name is : "+AccountInfoString(ACCOUNT_NAME), 10, 25, "System", 10, clrAqua);
  CREATE_TEXT_LABEL ("Your Acc # is : "+IntegerToString(AccountInfoInteger(ACCOUNT_LOGIN)), 10, 40, "Lucida Console", 25, clrMagenta);
  CREATE_TEXT_LABEL ("And your money is : "+DoubleToString(AccountInfoDouble(ACCOUNT_BALANCE), 2), 10, 70, "Courier New", 30, clrRed);
  CREATE_TEXT_LABEL ("J", 10, 95, "Wingdings", 50, clrGold); //<<== try also Webdings ;)
 
  PlaySound("wait.wav");
  }

//+------------------------------------------------------------------+

bool CREATE_TEXT_LABEL (string txt, int x, int y, string font_type, int font_size, color colour)
  {
  bool created;
  static int no;
  no ++;
  string name = "My text label "+ IntegerToString(no);
  created = ObjectCreate(0,name, OBJ_LABEL, 0, 0, 0);
  if (created == true)
    {
    ObjectSetString( 0, name, OBJPROP_TEXT, txt);
    ObjectSetInteger(0, name, OBJPROP_CORNER, 0);        // <<== corner top left, play with it
    ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x);
    ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y);
    ObjectSetInteger(0, name, OBJPROP_SELECTABLE, true); // <<== make it selectable
    ObjectSetInteger(0, name, OBJPROP_SELECTED, false);  // <<== play with it, turn it to true
    ObjectSetString (0, name, OBJPROP_FONT, font_type);
    ObjectSetInteger(0, name, OBJPROP_FONTSIZE, font_size);
    ObjectSetInteger(0, name, OBJPROP_COLOR, colour);
    }
  return (created);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Paul Anscombe
3995
Paul Anscombe 2012.06.23 16:20  
onewithzachy:

Hi MaxTrader,

How's your weekend ?,

This is a script, and enjoy the weekend

:D

Hi  thanks very much for the prompt reply.  Your code certainly solves the problem, but does it not seem crazy that with all these features you can't use a line feed in a text string?

 

anyway thanks again

 

 

 

Alexander Piechotta
6929
Alexander Piechotta 2012.06.24 01:26  
MyComment - new comments added without deleting existing ones.
  • votes: 3
  • 2011.09.22
  • Alexander Piechotta | English Russian Spanish Portuguese
  • mql5.com
New comments added to a chart without deleting existing ones.
onewithzachy
2271
onewithzachy 2012.06.24 03:16  
MaxTrader:

Hi  thanks very much for the prompt reply.  Your code certainly solves the problem, but does it not seem crazy that with all these features you can't use a line feed in a text string?

anyway thanks again

Hi MaxTrader, 

You're welcome. it's actually drawing text not writing one. :D 

:D 

0xFF
3
0xFF 2013.04.10 15:14  

Hi All,

I would like to ask, why the OBJPROP_TEXT is limited to 63 characters?

I know, that I can use a class CCanvas and TextOut(...) to avoid this problem, but why to make it complicated? The OBJ_LABEL is already made, so why it is so limited???

Is there any possibility to change restriction for the OBJPROP_TEXT from 63 to 511 characters?

Thank you.


Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
Alain Verleyen
Moderator
30640
Alain Verleyen 2013.04.10 15:35  
0xFF:

Hi All,

I would like to ask, why the OBJPROP_TEXT is limited to 63 characters?

I know, that I can use a class CCanvas and TextOut(...) to avoid this problem, but why to make it complicated? The OBJ_LABEL is already made, so why it is so limited???

Is there any possibility to change restriction for the OBJPROP_TEXT from 63 to 511 characters?

Thank you.


Write to ServiceDesk, only them can respond.
Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
To add comments, please log in or register