How return the value of 2 trend lines by ObjectGet function

 

Hello ;

I would like the distance between 2 trend lines (the height) so i begin to create a program which can get the object property like (price and time) . My problem is I can take those information for one trend line but not for the one (there is to)

as you can see in the pictures, I draw 2 Horizontal line for one trend line (because we must use 2 coordinates.) . but for the other trend I can know how to do ??? to have its object property .


here is the code

int start()
  {
   int    counted_bars=IndicatorCounted();
   double valeur1 ,valeur2,valeur3,valeur4;
   datetime temps1;
  datetime temps2;
  datetime temps3;
  datetime temps4;
   
   
    int  obj_total = ObjectsTotal();  
    int compteur=0;
    string name ; 
    bool trouve = false;
//----

     for(int i = 0; i < obj_total; i++)
     {
     
     
     
       name = ObjectName(i);
       
       if((ObjectType(name) == OBJ_TREND)&&(trouve==false)&&(compteur!=2))
         {
         
            valeur1 = ObjectGet(name,OBJPROP_PRICE1);
             temps1 = ObjectGet(name,OBJPROP_TIME1);
            
            valeur2 =   ObjectGet(name,OBJPROP_PRICE2);
             temps2 = ObjectGet(name,OBJPROP_TIME2);
             
             /*
              valeur3 = ObjectGet(name,OBJPROP_PRICE3);
             temps3 = ObjectGet(name,OBJPROP_TIME3);
            */
             
             
              if(!ObjectCreate("ligne1",OBJ_HLINE,0,temps1,valeur1))
           {
             Print("error: can't create text_object! code #",GetLastError());
            return(0);

           }
           
             if(!ObjectCreate("ligne2",OBJ_HLINE,0,temps2,valeur2))
           {
             Print("error: can't create text_object! code #",GetLastError());
            return(0);

           }
           
           compteur ++;
           
           /*
            if(!ObjectCreate("ligne3",OBJ_HLINE,0,temps3,valeur3))
           {
             Print("error: can't create text_object! code #",GetLastError());
            return(0);

           }
           
           */
           
            
         
         }
         
         else 
                    // the other trend line 
         
         {
         
            valeur3 = ObjectGet(name,OBJPROP_PRICE1);
             temps3 = ObjectGet(name,OBJPROP_TIME1);
             
                 if(!ObjectCreate("ligne3",OBJ_HLINE,0,temps3,valeur3))
           {
             Print("error: can't create text_object! code #",GetLastError());
            return(0);

           }
           
         
         
         }
         
     }    
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

please, can you tell me what's wrong ?? and how to do or theeasy way to procede for calculating the height of 2 trend lines (it's like a canal)

thanks a lot

 

Once you have got the values for the first TL set a bool to true, if the bool is true when you find the next TL you use the second set of variables to capture Price1 & 2 and Time1 & 2 for the 2nd TL.

By the way, the TLs on your chart are not parallel so the distance between them will vary along their length.

 

Hello ;

do you mea like this ???

int start()
  {
   int    counted_bars=IndicatorCounted();
   double valeur1 ,valeur2,valeur3,valeur4;
   datetime temps1;
  datetime temps2;
  datetime temps3;
  datetime temps4;
   
   
    int  obj_total = ObjectsTotal();  
   
    string name ; 
        
        // here bool 
    bool trouve = false;
//----

     for(int i = 0; i < obj_total; i++)
     {
     
     
     
       name = ObjectName(i);
       
           // we try to get the first line
       if((ObjectType(name) == OBJ_TREND)&&(trouve==false))
         {
         
            valeur1 = ObjectGet(name,OBJPROP_PRICE1);
             temps1 = ObjectGet(name,OBJPROP_TIME1);
            
            valeur2 =   ObjectGet(name,OBJPROP_PRICE2);
             temps2 = ObjectGet(name,OBJPROP_TIME2);
             
            
            // we draw the 2 HL 
             
              if(!ObjectCreate("ligne1",OBJ_HLINE,0,temps1,valeur1))
           {
             Print("error: can't create text_object! code #",GetLastError());
            return(0);

           }
           
             if(!ObjectCreate("ligne2",OBJ_HLINE,0,temps2,valeur2))
           {
             Print("error: can't create text_object! code #",GetLastError());
            return(0);

           }
           
             // we put the bool to true 
                         
                          trouve = true ;
           
          
           
            
         
         }
         
         else 
                    // the other trend line 
         
         {
         
             valeur3 = ObjectGet(name,OBJPROP_PRICE1);
             temps3 = ObjectGet(name,OBJPROP_TIME1);
             
                 if(!ObjectCreate("ligne3",OBJ_HLINE,0,temps3,valeur3))
           {
             Print("error: can't create text_object! code #",GetLastError());
            return(0);

           }
                   
                   
                     valeur4 = ObjectGet(name,OBJPROP_PRICE2);
             temps4 = ObjectGet(name,OBJPROP_TIME2);
             
                 if(!ObjectCreate("ligne3",OBJ_HLINE,0,temps4,valeur4))
           {
             Print("error: can't create text_object! code #",GetLastError());
            return(0);

           }
           
         
         
         }
         
     }    
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Yes I know that the TL is not parallel in the picture but I want just to project the TL like a mirror . I thought also to use Standard deviation channel. but the problem is it calculate the prices of the middle line !!

Reason: