Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
nofear91
24
nofear91 2015.06.09 14:47 

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.




Alain Verleyen
Moderator
28607
Alain Verleyen 2015.06.09 16:39  
You are answering yourself, use a labels.
nofear91
24
nofear91 2015.06.09 17:05  
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.
Alain Verleyen
Moderator
28607
Alain Verleyen 2015.06.09 20:25  
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.
nofear91
24
nofear91 2015.06.10 07:41  
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);
      
}
mar
1143
mar 2015.06.10 09:56  
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.
nofear91
24
nofear91 2015.06.10 11:27  
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? 
mar
1143
mar 2015.06.10 12:20  

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.

nofear91
24
nofear91 2015.06.10 13:29  
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");
}
nofear91
24
nofear91 2015.06.10 19:05  
nobody help me???
/
To add comments, please log in or register