Download MetaTrader 5

please help fix this label function

To add comments, please log in or register
Preet Kanwaljit Singh
43
Preet Kanwaljit Singh  

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
10568
Keith Watford  

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
18963
Vasyl Nosal  
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