attaching a label to the bar

 

I want to create nice label at the right corner of my bar:

      ObjectCreate("(D)", OBJ_LABEL, 0, 0, 0);

      ObjectSetText("(D)", "(D)", 16, "Times New Roman", Blue);

      ObjectSet("(D)", OBJPROP_TIMEFRAMES, OBJ_PERIOD_H1); 

      ObjectSet("(D)",OBJPROP_CORNER,CORNER_RIGHT_LOWER);

      ObjectSet("(D)", OBJPROP_XDISTANCE, 210);

      ObjectSet("(D)", OBJPROP_YDISTANCE, 50);

      ObjectSet("(D)", OBJPROP_ALIGN, ALIGN_RIGHT); 

 

I can move this label. But, is there I way to connect label to specific bar, or turn OBJ_LABEL to OBJ_TEXT? 

 
Use OBJ_TEXT and anchor by time and price
 
How should I know what is the time and price in the lower right corner of my chart? I can move in the history in the past or in the future and I can't know precisely what is the bar now in the right corner. Or can I? 
 
bool GetChartLimits(int& iLeft, int& iRight, double& top, double& bot){
      // In the tester (visual mode,) on the first tick, these routines return
      // left=100, right=37 (depends on default bar scaling.) This is what the
      // chart looks like when you maximize it while it is generating the FXT
      // file. After that, it appears like the left/right are correct but the
      // hi/lo are one tick behind the displayed chart. I don't know about
      // live charts.
   }
   top   = WindowPriceMax();
   bot   = WindowPriceMin();
   iLeft    = WindowFirstVisibleBar();
   iRight  = iLeft-WindowBarsPerChart();
   if (iRight < 0)   iRight = 0;                      // Chart is shifted.
   return(true);
}
 
jkmaks:
How should I know what is the time and price in the lower right corner of my chart? I can move in the history in the past or in the future and I can't know precisely what is the bar now in the right corner. Or can I? 

you said

jkmaks:

I can move this label. But, is there I way to connect label to specific bar, or turn OBJ_LABEL to OBJ_TEXT? 

So it appeared to me that you want to anchor the object to a specific bar

Reason: