help to trace the projection of angle arms

 

     

I try to draw the projection of angle arms  but I block

this is what I did to trace the angle based on the ZigZag

first two functions for the top and buttom like this 

 

 double GetTops(int shift, int &top  ){
      int found = 0 ,
      i = 0 ;
      double hi = 0 ;
        
    for(i = 0 ; i < Bars ; i++){
        
           hi = iCustom(NULL,0,"ZigZag",0,i);
           if(hi !=0 && hi == High[i])
            found++ ; 
           if(found == shift )
          {
           top = i ;         
           return(hi) ;  
           }
            
             }
       return(hi) ;                
     }


  double GetButtoms(int shift , int &buttom){
      int found = 0 ,
      i = 0 ;
      double lo = 0 ;
        
    for(i = 0 ; i < Bars ; i++){
        
           lo = iCustom(NULL,0,"ZigZag",0,i);
           if(lo !=0 && lo == Low[i]) found++ ;     
           if(found == shift ) 
              {
           buttom = i ;         
           return(lo) ;  
           }
             }
       return(lo) ;                
     }

 

    the parameters calling by reference  for returning values bars indices

     second  function ObjectCreate  to draw trend line 

   

 void SetArms(string name,datetime t1, double pr1,datetime t2, double pr2)
    {
     if(ObjectFind(name) != 0)
        {
         ObjectCreate(name, OBJ_TREND, 0, t1,pr1,t2,pr2);
         ObjectSet(name, OBJPROP_COLOR, AreaColor);
         ObjectSet(name, OBJPROP_RAY, 0);
       } 
       else
        {
         if(ObjectGet(name,OBJPROP_TIME1)!=t1 || ObjectGet(name,OBJPROP_PRICE1)!=pr1 || ObjectGet(name,OBJPROP_TIME2)!=t2 || ObjectGet(name,OBJPROP_PRICE2)!=pr2)
         {ObjectDelete(name);}
        } 
   } 

 

     and some code in the start function like this it same working at the moment

 

 

for(int i = 4 ; i > 0 ;i-=2){  
         
         int  a,b,c,d ;
         double A, B , C , D  ;
         
          A = GetTops(i,ShiftTopA) ;
               a = ShiftTopA ;
          B = GetButtoms(i,ShiftButtomB) ;
               b = ShiftButtomB ; 
          C = GetTops(i-1,ShiftTopC) ;    
               c = ShiftTopC ;
          D = GetButtoms(i-1,ShiftButtomD) ;
               d = ShiftButtomD ;

               if(A > C  ){
              
        SetArms("High_High"+IntegerToString(i),Time[a],A,Time[c],C) ;
        SetArms("High_Low"+IntegerToString(i),Time[c],C,Time[b],B) ;
        }  
               if(A < C  ){
               
        SetArms("Low_Low"+IntegerToString(i),Time[b],B,Time[d],D) ;
        SetArms("High_Low_"+IntegerToString(i),Time[c],C,Time[b],B) ;  
           }          
      }   

 

    this is what I have at the moment and what I want on the image below Last

    if someone can help me

 

     

 

   

 
up ....
 

The most probable reason why nobody has posted yet, is maybe because we don't understand your request and logic (well, at least I don't - maybe someone else does).

In your graph, your point "D" is in the future, yet your code calculates all points A to D from a history in the past, and in so doing draw your lines in the past and not in the future as you have referenced.

Also, why delete a Chart Object only to recreate it again? Just move it instead with "ObjectMove()". I am referring the the following line of code:

if(ObjectGet(name,OBJPROP_TIME1)!=t1 || ObjectGet(name,OBJPROP_PRICE1)!=pr1 || ObjectGet(name,OBJPROP_TIME2)!=t2 || ObjectGet(name,OBJPROP_PRICE2)!=pr2)
         {ObjectDelete(name);}
 

 coordinates of the points calculation (this is example, code can be optimized)

int         i;
double      APointPrice,BPointPrice,CPointPrice,DPointPrice,breaking;
datetime    APointTime,BPointTime,CPointTime,DPointTime;

// start from zero bar
i=0;

// skip the first point
breaking=0;
   while (breaking==0)
      {
      breaking=iCustom(NULL,0,"ZigZag",12,5,3,0,i);
      i++;
      }

// point C
breaking=0; 
   while (breaking==0)
      {
      breaking=iCustom(NULL,0,"ZigZag",12,5,3,0,i);
      i++;
      }
   CPointTime=Time[i-1];
   CPointPrice=breaking;
   Print("TimeC=",TimeToStr(CPointTime),"   priceC=",CPointPrice);

// point B
breaking=0; 
   while (breaking==0)
      {
      breaking=iCustom(NULL,0,"ZigZag",12,5,3,0,i);
      i++;
      }
   BPointTime=Time[i-1];
   BPointPrice=breaking;
   Print("TimeB=",TimeToStr(BPointTime),"   priceB=",BPointPrice);

// point A
breaking=0;
   while (breaking==0)
      {
      breaking=iCustom(NULL,0,"ZigZag",12,5,3,0,i);
      i++;
      }
   APointTime=Time[i-1];
   APointPrice=breaking;
   Print("TimeA=",TimeToStr(APointTime),"   priceA=",APointPrice);

// point D
DPointTime=(CPointTime-APointTime)+CPointTime;

// Here you need to add the desired formula to calculate the projection
if (APointPrice>CPointPrice) DPointPrice=CPointPrice-(APointPrice-CPointPrice);
else DPointPrice=CPointPrice+(CPointPrice-APointPrice);
   Print("TimeD=",TimeToStr(DPointTime),"   priceD=",DPointPrice);
 
thank you I'll test the code ...
Reason: