Creating an indicator do display a watermark-kind of text

To add comments, please log in or register
Martin Bittencourt
611
Martin Bittencourt  

Hi,

I'm trying to create an indicator what will display some text in a watermark style: centered and with size and opacity configurable.

I don't have much experience with objects in MT5; the only text kind of thing I did was with OBJ_LABEL, but I'm not sure this is the proper way to go this time; there doesn't seem to be any way of changing its opacity.

As for now, what I have is

ObjectCreate(0,glTextName,OBJ_LABEL,0,0,0,0,0,0,0);

ObjectSetInteger(0,glTextName,OBJPROP_COLOR,Color);
ObjectSetInteger(0,glTextName,OBJPROP_FONTSIZE,FontSize);
//ObjectSetString(0,glTextName,OBJPROP_FONT,"Arial Bold"); 
ObjectSetString(0,glTextName,OBJPROP_TEXT,"mytexthere");        
        
ObjectSetInteger(0,glTextName,OBJPROP_XDISTANCE,200);
ObjectSetInteger(0,glTextName,OBJPROP_YDISTANCE,100);
ObjectSetInteger(0,glTextName,OBJPROP_CORNER,CORNER_LEFT_UPPER);
//OBJPROP_ANCHOR ENUM_ANCHOR_POINT      
//OBJPROP_XSIZE 

From this point, what is lacking is:

  • A way to always centralize the text. The text will not always have the same size, so an automatic way of the label readjusting its size to the size of the text is welcomed. If not, I will need a way of knowing the size the text is going to need to readjust the label's size.
  • A way to configure the text opacity

Any help appreciated!

William Roeder
21914
William Roeder  
  1. You need to get the size of the text and adjust from there.
              Object Functions / TextGetSize - Reference on algorithmic/automated trading language for MetaTrader 5
  2. The attached indicator just externs RGB values, giving any color and any opacity.
Files:
Martin Bittencourt
611
Martin Bittencourt  
William Roeder:
  1. You need to get the size of the text and adjust from there.
              Object Functions / TextGetSize - Reference on algorithmic/automated trading language for MetaTrader 5
  2. The attached indicator just externs RGB values, giving any color and any opacity.

Thanks for the textgetsize function!

Regarding the indicator, I only work with MT5, so I don't even know how could I use it :/

Plus, I'm still finding trouble to change the label size to be equal to the needed size. When I write the text on it (ObjectSetString(0,glTextName,OBJPROP_TEXT,glRemList[glLastRem]);), the label just don't appropriately readjust, and setting XSIZE and YSIZE don't work, they are read-only :/ And I also don't know how to make it go to the background :/
Nagisa Unada
600
Nagisa Unada  
This is for your sample...
Files:
To add comments, please log in or register