attaching a label to the bar

Back to topics list To post a new topic, please log in or register
avatar
11
jkmaks 2016.04.07 10:11
 

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? 

avatar
Moderator
3407
GumRai 2016.04.07 10:50 #
 
Use OBJ_TEXT and anchor by time and price
avatar
11
jkmaks 2016.04.07 16:23 #
 
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? 
avatar
12985
WHRoeder 2016.04.07 17:54 #
 
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);
}

avatar
Moderator
3407
GumRai 2016.04.07 21:28 #
 
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

Back to topics list  

To add comments, please log in or register