Download MetaTrader 5
To add comments, please log in or register
Do you keep a blog? Place a link to MQL5.community there and make money!
jkmaks
36
jkmaks 2016.04.07 08: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? 

Keith Watford
Moderator
7906
Keith Watford 2016.04.07 08:50  
Use OBJ_TEXT and anchor by time and price
jkmaks
36
jkmaks 2016.04.07 14: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? 
whroeder1
13610
whroeder1 2016.04.07 15: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);
}
Keith Watford
Moderator
7906
Keith Watford 2016.04.07 19: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

/
To add comments, please log in or register