Download MetaTrader 5

please help fix this label function

To add comments, please log in or register
You sell neither signals nor apps? No problem, everyone can make profit!
Preet Gill
43
Preet Gill 2015.08.11 05:00 

my function call line in start() is

  LN(1,"+ 100", H, White);

my function is


void LN(double n, string nm, double val, color CL)

{

   string NN = nm + DoubleToStr(n,0);

   ObjectDelete(NN);

   ObjectCreate(0,NN,OBJ_HLINE,0,0,val);

   ObjectSet(NN,OBJPROP_COLOR,CL);

   

   string nmL = NN + "_Label";

   double VL = ObjectGet(NN,OBJPROP_PRICE1)

   ;

   ObjectCreate(0,nmL,OBJ_LABEL,Time[0],VL);

   ObjectSetText(nmL,nm,10,"Arial",CL);

   


    

}

my problem is that line labels are not being shown on chart, i know i am doing something wrong but after countless hours of wasting time i decided to look for expert opinion

please guide

Keith Watford
Moderator
9614
Keith Watford 2015.08.11 06:58  

Pleas use variable names that help to recognise what they are.

Even your small section of code is not easy to follow

ObjectCreate(0,nmL,OBJ_LABEL,Time[0],VL);

 A label uses x and y pixels as co-ordinates, not time and price

Vasyl Nosal
18537
Vasyl Nosal 2015.08.11 07:46  
GumRai:

Pleas use variable names that help to recognise what they are.

Even your small section of code is not easy to follow

 A label uses x and y pixels as co-ordinates, not time and price

Yes.

OBJECT_SET(X_DISTANCE) 

 OBJECT_SET(Y_DISTANCE) 

To add comments, please log in or register