How to read TrendLIne(object) value

Cromo
393
Cromo  

Hello,

I want to read the price from the trend line object.



I just want to get the price (upper and lower line ) on the current bar.



    for(int k=0;k<ObjectsTotal(0,0, OBJ_TREND);k++) 
      { 
         string name = ObjectName(0, k, 0, OBJ_TREND); 
           
        if(ObjectGet(name,OBJPROP_TIME1)==Time[0])
         {
            double VALUE= ObjectGetDouble(0, name, OBJPROP_PRICE1);
            double time= ObjectGetDouble(0, name, OBJPROP_TIME1);
          Print(name+"="+VALUE+time);
            
        }
      }
   

This is my code.

To get the onject price on the current bar, I used Time[0]

But it is not working.

Is this correct?

Marco vd Heijden
Moderator
13504
Marco vd Heijden  
OBJPROP_TIME
OBJPROP_PRICE
William Roeder
24704
William Roeder  
Cromo: To get the onject price on the current bar, I used Time[0] But it is not working. Is this correct?
  1. Your code only select a trend line what has the first coordinate at Time[0]. Were they both drawn from bar zero backwards? Otherwise, you will not select them.
  2. Your code reads one of the two trend line coordinates; has nothing to do what you want.
  3. Perhaps you should read the manual.
              ObjectGetValueByShift - Object Functions - MQL4 Reference
Cromo
393
Cromo  

Hi, William

Great hint.

Thanks.

ObjectGetValueByShift

solve the issue!