How to give a name to the horizontal lines with label?

 

Hello,

 

 

I'm working on it fibonacci retracement and i want to give names to the horizontal lines with label. How can do that?

 

Thank you for helping.




 
You are answering yourself, use a labels.
 
angevoyageur:
You are answering yourself, use a labels.
I know but how to add label to my code. I wrote ObjectCreate and ObjectSetText but i cant see on the chart window.
 
nofear91:
I know but how to add label to my code. I wrote ObjectCreate and ObjectSetText but i cant see on the chart window.
Show your code if you need help.
 
angevoyageur:
Show your code if you need help.
if(!ObjectCreate(chart_ID,name,OBJ_FIBO,sub_windows,time1,price1,time2,price2))
      {
         Print(__FUNCTION__,
                  ": failed to create\"Fibonacci Retracement\"! Error Code= ",GetLastError());
                  return(false);
      }
         ObjectSetText(chart_ID,"D1",10,NULL,clrBlue);
         ObjectSetInteger(chart_ID, name,OBJPROP_COLOR,clr);
         ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
         ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
         ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
         ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
         ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
         ObjectSetInteger(chart_ID,name,OBJPROP_RAY_LEFT,ray_left);
         ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,ray_right);
         ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
         ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
         return(true);
      
}
 
In your case ObjectSetText() sets the description of the created line that can only be seen in the object properties. If you want to see the description in the chart you have to add an OBJ_LABEL and place it right next to your horizontal line.
 
mar:
In your case ObjectSetText() sets the description of the created line that can only be seen in the object properties. If you want to see the description in the chart you have to add an OBJ_LABEL and place it right next to your horizontal line.
Ok but horizontal lines are moving. Label is not moving. How can do it moving labels with horizontal lines? 
 

If you mean that you change the lines manually then use CHARTEVENT_OBJECT_CHANGE or/and CHARTEVENT_OBJECT_DRAG. Then you know that a horizontal line has changed and you can change your label accordingly.

 
mar:

If you mean that you change the lines manually then use CHARTEVENT_OBJECT_CHANGE or/and CHARTEVENT_OBJECT_DRAG. Then you know that a horizontal line has changed and you can change your label accordingly.

 

No, i'm not changing the lines manually.

I give the names of the 4 horizontal lines(d1,d2,h1,h2) and when changed the  lines i want to change with labels. How will i do? 

bool FiboLevelsSet(int  levels,
                  double &values[],
                  color &colors[],
                  ENUM_LINE_STYLE &styles[],
                  int &widths[],
                  const string &names[],
                  const long chart_ID=0,
                  const string name="FiboLevels")

{
   if(levels != ArraySize(colors) || levels != ArraySize(styles) || levels != ArraySize(widths) || levels!=ArraySize(widths))
      {
         Print(__FUNCTION__,":array length does not correspond to the number of levels, error!");
         return(false);
      }
      
      ObjectSetInteger(chart_ID,name,OBJPROP_LEVELS,levels);
   for(int i=0;i<levels;i++)
      {   
         ObjectSetDouble(chart_ID,name,OBJPROP_LEVELVALUE,i,values[i]);
         ObjectSetInteger(chart_ID,name,OBJPROP_LEVELCOLOR,i,colors[i]);
         ObjectSetInteger(chart_ID,name,OBJPROP_LEVELSTYLE,i,styles[i]);
         ObjectSetInteger(chart_ID,name,OBJPROP_LEVELWIDTH,i,widths[i]);
         ObjectSetString(chart_ID,name,OBJPROP_LEVELTEXT,i,names[i]);
      }   
   return(true);
}

void SetupRetrFibo() {
   double v[4];
   color c[4];
   ENUM_LINE_STYLE s[4];
   int w[4];
   string n[4];
   v[0] = 0.5;c[0] = 255;s[0] = 1;w[0] = 1;n[0] = "d1"; 
   v[1] = 0.618; c[1] = 255; s[1] = 1; w[1] = 1;n[1] = "d2";
   v[2] = -0.236; c[2] = 255; s[2] = 1; w[2] = 1;n[2] = "h1";
   v[3] = -0.618; c[3] = 255; s[3] = 1; w[3] = 1;n[3] = "h2";
   FiboLevelsSet(4,v,c,s,w,n,0,"RETR");
}
 
nobody help me???
 
nofear91:
nobody help me???

I have the same problem bro, searching like crazy, nobody answers. Just a little caption over the lines drawed in the chart, only this.

Reason: