Download MetaTrader 5
To add comments, please log in or register
Download MetaTrader 5 and start trading today!
Charles Vanderstelt
101
Charles Vanderstelt 2011.04.01 01:04 

Can someone add a label to this indicator at the end of the line where I can add text through the properties window of the indicator? link to codebase

please pretty please...

It should look similar to this price label but I want to add custom text.



 






  

    
   




  

 

   




  
   
    
    
     

   

Charles Vanderstelt
101
Charles Vanderstelt 2011.04.02 06:43  

Anyone have any idea as to how this would be done?

Can it be done?


I am guessing ObjectCreate but I have no idea what represents the line or how to attach a label to the line.

I want an external string at the end of the price of the indicator....

Charles Vanderstelt
101
Charles Vanderstelt 2011.04.04 12:13  
Any tips or suggestions would be appreciated.
Charles Vanderstelt
101
Charles Vanderstelt 2011.04.09 05:00  

Still waiting for help?

Ian Venner
2583
Ian Venner 2011.04.10 03:54  
Charles Vanderstelt
101
Charles Vanderstelt 2011.04.10 06:38  
thanks for reference. this will be my homework for weekend.
Charles Vanderstelt
101
Charles Vanderstelt 2011.04.11 11:30  

Ok any other ideas? I was unable to add a label to the indicator that displays text. This is very hard to do.

Journey Rider
31
Journey Rider 2014.08.30 18:00  
// See https://docs.mql4.com/constants/objectconstants/enum_object/obj_label

//+------------------------------------------------------------------+
//| Create a text label - Place this in your global scope body       |
//+------------------------------------------------------------------+
bool LabelCreate(const long              chart_ID=0,               // chart's ID
                 const string            name="Label",             // label name
                 const int               sub_window=1,             // subwindow index
                 const int               x=150,                      // X coordinate
                 const int               y=150,                      // Y coordinate
                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // chart corner for anchoring
                 const string            text="Label",             // text
                 const string            font="Arial",             // font
                 const int               font_size=10,             // font size
                 const color             clr=clrRed,               // color
                 const double            angle=0.0,                // text slope
                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // anchor type
                 const bool              back=false,               // in the background
                 const bool              selection=false,          // highlight to move
                 const bool              hidden=true,              // hidden in the object list
                 const long              z_order=0)                // priority for mouse click
  {
//--- reset the error value
   ResetLastError();
//--- create a text label
   if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
     {
      Print(__FUNCTION__,
            ": failed to create text label! Error code = ",GetLastError());
      return(false);
     }
//--- set label coordinates
   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
//--- set the chart's corner, relative to which point coordinates are defined
   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
//--- set the text
   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
//--- set text font
   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
//--- set font size
   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
//--- set the slope angle of the text
   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
//--- set anchor type
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set color
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- display in the foreground (false) or background (true)
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the label by mouse
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution
   return(true);
  }


//+------------------------------------------------------------------+
//| Then call LableCreate function:                                  |
//| Put this in your void OnStart() if it is a constant lable,       |
//| or this in your OnCalculate() if the text value is variable.     |
//+------------------------------------------------------------------+

   string MyLableString = "This is my lable";
   LabelCreate(0,"Tool Tip Text",1,50,50,CORNER_LEFT_UPPER,MyLableString,"Arial",10,
      Yellow,0.0,ANCHOR_CENTER,false,true,true,0);
/
To add comments, please log in or register