How to get PriceLevel of TrendLine (Ray in the future direction)?

 

Hey... the Trenline already exists, but i cant get the Pricelevel of it on the current bar...

i tried it like this, but it still returns 0

      
 double getCurrentPriceOfTrendLine(const string name)
{
  int type = (int)ObjectGetInteger(0, name, OBJPROP_TYPE);
  if(type == OBJ_TREND)
  {
    datetime dt1 = (datetime)ObjectGetInteger(0, name, OBJPROP_TIME, 0);
    datetime dt2 = (datetime)ObjectGetInteger(0, name, OBJPROP_TIME, 1);
    int i1 = iBarShift(NULL, 0, dt1, true);
    int i2 = iBarShift(NULL, 0, dt2, true);
    if(i1 <= i2 || i1 == -1 || i2 == -1)
    {
      Print("Incorrect line: ", name);
      return 0;
    }
    double p1 = ObjectGetDouble(0, name, OBJPROP_PRICE, 0);
    double p2 = ObjectGetDouble(0, name, OBJPROP_PRICE, 1);
        
    double k = -(p1 - p2)/(i2 - i1);
    double b = -(i1 * p2 - i2 * p1)/(i2 - i1);
        
    return b;
  }
  return 0;
}
Edit: This Function was in MQL4 i think...
 
Bayne:

Hey... the Trenline already exists, but i cant get the Pricelevel of it on the current bar...

i tried it like this, but it still returns 0

Edit: This Function was in MQL4 i think...


Hmm... I copied your code wholesale, and it works perfectly... 

 
Bayne:

Hey... the Trenline already exists, but i cant get the Pricelevel of it on the current bar...

i tried it like this, but it still returns 0

Edit: This Function was in MQL4 i think...
Yes...it works.
Reason: