CommentLab Problem Line Break

 

Hello, I use this function for commenting.

//+------------------------------------------------------------------+
void CommentLab(string CommentText)  
{
   string CommentLabel, label_name;
   int CommentIndex = 0;
  
   label_name = "CommentLabel"; 

   if (CommentText == "")
   {
      //  delete all Comment texts
      while(ObjectFind(0,label_name) >= 0)
      {
         ObjectDelete(0,label_name);
         CommentIndex++;
      }
//    return;
   }
  

//    Print("CommentText: ",CommentText);
  
      ObjectCreate(0,label_name,OBJ_LABEL,0,0,0);           
      ObjectSetInteger(0,label_name, OBJPROP_CORNER, 0);
      //--- set X coordinate
      ObjectSetInteger(0,label_name,OBJPROP_XDISTANCE,5);
      //--- set Y coordinate
      ObjectSetInteger(0,label_name,OBJPROP_YDISTANCE,15);
      //--- define text color
      ObjectSetInteger(0,label_name,OBJPROP_COLOR,clrGoldenrod);
      //--- define text for object Label
      ObjectSetString(0,label_name,OBJPROP_TEXT,CommentText);
      //--- define font
      ObjectSetString(0,label_name,OBJPROP_FONT,"Arial");
      //--- define font size
      ObjectSetInteger(0,label_name,OBJPROP_FONTSIZE,12);
      //--- 45 degrees rotation clockwise
//    ObjectSetDouble(0,label_name,OBJPROP_ANGLE,-45);
      //--- disable for mouse selecting
      ObjectSetInteger(0,label_name,OBJPROP_SELECTABLE,true);
      //--- draw it on the chart
      ChartRedraw(0);                                     
  
}
//+------------------------------------------------------------------+

I am using comment like this

CommentLab( StringConcatenate("Highest Sell " + highestsell + " Lot - Highest Buy " + highestbuy + " Lot") );

It outputs just one line

Now i want it output as 2 line like,

Highest Sell 1.1434

Highest Buy 1.4544


How can i do that, how can i make line break with this function??

 
Mehmet Cak: How can i do that, how can i make line break with this function??

You make two objects.

 
William Roeder:

You make two objects.

I tried it before like

CommentLab( StringConcatenate("Highest Sell " + highestsell + " Lot " ) );

CommentLab( StringConcatenate(""Highest Buy " + highestbuy + " Lot") );

but i can see only the last row. First one disapper when second line comes :-(

 
Mehmet Cak:

I tried it before like

CommentLab( StringConcatenate("Highest Sell " + highestsell + " Lot " ) );

CommentLab( StringConcatenate(""Highest Buy " + highestbuy + " Lot") );

but i can see only the last row. First one disapper when second line comes :-(

Hello,

I suggest to you to pass in your call 2 parameters, labelname and position :

//+------------------------------------------------------------------+
void CommentLab(string CommentText, string label_name, int y_pos)  
{
   string CommentLabel;
   int CommentIndex = 0;
  
   if (CommentText == "")
   {
      //  delete all Comment texts
      while(ObjectFind(0,label_name) >= 0)
      {
         ObjectDelete(0,label_name);
         CommentIndex++;
      }
//    return;
   }
  

//    Print("CommentText: ",CommentText);
  
      ObjectCreate(0,label_name,OBJ_LABEL,0,0,0);           
      ObjectSetInteger(0,label_name, OBJPROP_CORNER, 0);
      //--- set X coordinate
      ObjectSetInteger(0,label_name,OBJPROP_XDISTANCE,5);
      //--- set Y coordinate
      ObjectSetInteger(0,label_name,OBJPROP_YDISTANCE,y_pos);
      //--- define text color
      ObjectSetInteger(0,label_name,OBJPROP_COLOR,clrGoldenrod);
      //--- define text for object Label
      ObjectSetString(0,label_name,OBJPROP_TEXT,CommentText);
      //--- define font
      ObjectSetString(0,label_name,OBJPROP_FONT,"Arial");
      //--- define font size
      ObjectSetInteger(0,label_name,OBJPROP_FONTSIZE,12);
      //--- 45 degrees rotation clockwise
//    ObjectSetDouble(0,label_name,OBJPROP_ANGLE,-45);
      //--- disable for mouse selecting
      ObjectSetInteger(0,label_name,OBJPROP_SELECTABLE,true);
      //--- draw it on the chart
      ChartRedraw(0);                                     
  
}
//+------------------------------------------------------------------+

Then, you can call like this :

CommentLab( StringConcatenate("Highest Sell " + highestsell + " Lot " ),"comment_label_1", 15 );

CommentLab( StringConcatenate(""Highest Buy " + highestbuy + " Lot"),"comment_label_2", 25 ); 
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".