Group Horizontal Line with edit object

 

Hello everyone, can anyone help me with any method to group one object that positioning relative to a chart (Horizontal Line) with another that positioning relative to a security window (Edit) as shown in the picture?



 
Tran Nhat Minh :

Hello everyone, can anyone help me with any method to group one object that positioning relative to a chart (Horizontal Line) with another  that positioning relative to a security window (E dit)  as shown in the picture?



What?

 
Vladimir Karputov #:

What?

I have an idea to use ea to create a countdown timer pending order. There will be an edit object to inform the countdown time, this object will be attached to the horizontal line and it will move according to the horizontal line, but I have a problem that I don't know how to get the price coordinates of the horizontal line to change the coordinates of the edit accordingly. 
 
Tran Nhat Minh #: t I don't know how to get the price coordinates of the horizontal line

Perhaps you should read the manual. ObjectSetDoubleENUM_OBJECT_PROPERTY_DOUBLE → OBJPROP_PRICE
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

 
Tran Nhat Minh #: t I don't know how to get the price coordinates of the horizontal line

Yes i wrote that part wrong, the real problem is that i can't get the x,y coordinates of the horizontal line to fit the edit object but instead there is only function to get its value coordinates
 
.
Files:
 
Ernst Van Der Merwe #:
.

Oh, thank a million, the idea seems so simple but I can't think of it :))

 
Ernst Van Der Merwe #:
.

Your idea is to get the value of the Y_DISTANCE coordinate of Horizontal Line returned by the OnChartEvent function (in CHARTEVENT_MOUSE_MOVE), but there is a problem that when Ishrink or stretch the chart (CHARTEVENT_CHART_CHANGE), that value does not return the correct y coordinate of the price bar. 

Can you have any other idea that I can get the Horizontal Line's Y coordinate, or convert the price, time coordinate to x,y coordinate for example

 
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   static datetime time;
   static double price;
   if(sparam=="1" && id==CHARTEVENT_MOUSE_MOVE && labl.Price(0)!=line.Price(0)) {
      labl.Price(0,line.Price(0));
      edit.X_Distance((int)lparam);
      edit.Y_Distance((int)dparam);
      int wnd;
      ChartXYToTimePrice(ChartID(),(int)lparam,(int)dparam,wnd,time,price);
      ChartRedraw(); }
//---
   if(id==CHARTEVENT_CHART_CHANGE) {
      int x,y;
      ChartTimePriceToXY(ChartID(),0,time,price,x,y);
      edit.X_Distance(x);
      edit.Y_Distance(y);
      ChartRedraw(); }
  }
//+------------------------------------------------------------------+
 
Ernst Van Der Merwe #:

oh, thank you very much

Reason: