Can anyone expert coder find my mistake ?

 

Hello., 

To all pro level coders.

I am facing an issue in displaying a line name "MX_3" just above the line, as illustraded in figure it is visible when I take cursor neer the line and if moved away it get disappeared.


I have updated the code but it is not working, unable to find the mistake.

 
Manpreet Singh: I am facing an issue in displaying a line name "MX_3" just above the line, as illustraded in figure it is visible when I take cursor neer the line and if moved away it get disappeared. I have updated the code but it is not working, unable to find the mistake.
You have not provided any code!
 
Fernando Carreiro #:
You have not provided any code!

Sorry, Forgot to attach file

Files:
Global_BD.mq5  37 kb
 
Manpreet Singh:

Hello., 

To all pro level coders.

I am facing an issue in displaying a line name "MX_3" just above the line, as illustraded in figure it is visible when I take cursor neer the line and if moved away it get disappeared.


I have updated the code but it is not working, unable to find the mistake.

And what is your problem, your issue?

Normally the graphical objects have their tooltip showing some information like name and the price if the mouse get close to it.

 
Carl Schreiber #:

And what is your problem, your issue?

Normally the graphical objects have their tooltip showing some information like name and the price if the mouse get close to it.

I just need That text "MX_3 just above the yellow line, now it is visible when mouse draged near to line. Price not required.

 
Manpreet Singh #:

I just need That text "MX_3 just above the yellow line, now it is visible when mouse draged near to line. Price not required.

Hello , this function may assist in what you want

/*
pass the line name first - which you have created before
*/ 
    /* Anchor options
    ANCHOR_LEFT_UPPER 
    ANCHOR_LEFT 
    ANCHOR_LEFT_LOWER
    ANCHOR_LOWER
    ANCHOR_RIGHT_LOWER
    ANCHOR_RIGHT
    ANCHOR_RIGHT_UPPER
    ANCHOR_UPPER
    ANCHOR_CENTER 
    */
void add_price_text_to_line(long chart_id,//which chart id 
                            string line_name,//the name of the hline
                            ENUM_ANCHOR_POINT anchor,//anchor of the text ,or positioning around the display point
                            datetime price_label_time,//the position of the price label in the x axis (time)
                            color price_label_color,
                            int price_label_fontsize,
                            string price_label_text){//NULL for just price
//first get the price line 
  ResetLastError();//reset the last error before this command so you know if it fails 
  double price=ObjectGetDouble(chart_id,line_name,OBJPROP_PRICE,0);
  //if there are no errors 
    //which means if the line exists 
      if(GetLastError()==0)
      {
      //now you have the price and the time so you create the text of the price  
        //give it a handy name 
          string name=line_name+"_PRICE_LABEL";
          ObjectCreate(chart_id,name,OBJ_TEXT,0,price_label_time,price);
          //and adjust it
            ObjectSetInteger(chart_id,name,OBJPROP_COLOR,price_label_color);
            ObjectSetInteger(chart_id,name,OBJPROP_FONTSIZE,price_label_fontsize);
            ObjectSetInteger(chart_id,name,OBJPROP_ANCHOR,anchor);
            //final property , if the label text sent is not empty set it as the label text 
            if(price_label_text!=NULL&&StringLen(price_label_text)>0)
              {
              ObjectSetString(chart_id,name,OBJPROP_TEXT,price_label_text);
              }//otherwise just place the price in
              else{
              ObjectSetString(chart_id,name,OBJPROP_TEXT,DoubleToString(price,_Digits));
              }
      ChartRedraw(chart_id);
      }else{
      Print("Line "+line_name+" Does not exist ");
      }
}
Reason: