Draw trend line with end - page 3

 
Alain Verleyen:

Could you please write correct English...

What that means ?

change the v to u

 
Seng Joo Thio:

Will work, just takes veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerrrry long for slower pcs (after all your code is inefficient)... and it'll completely fill up your chart window with lines.

Got a good pc, tried it and it will just freeze forever the terminal...could you show me the efficient way of doing it to all bars?

 
Hgu Gh:

Got a good pc, tried it and it will just freeze forever the terminal...could you show me the efficient way of doing it to all bars?

Just look at my earlier posts. Change your code accordingly. Then post your latest version here and we'll see how to improve further. 

 
Seng Joo Thio:

Just look at my earlier posts. Change your code accordingly. Then post your latest version here and we'll see how to improve further. 

i tried adding break but it would just give undesired results, the code below doesnt works after using it

 string rz= "RZ";

      for(int a= 0;a<Bars;a++)
         {
         string b = IntegerToString(a);
         {
            if(ObjectFind(0,"touched"+b)==0)
                  continue;
            ObjectCreate(0,rz+b,OBJ_TREND,0,Time[a],Low[a],Time[0],Low[a]);
            ObjectSetInteger(0,rz+b,OBJPROP_SELECTABLE,0);
            ObjectSetInteger(0,rz+b,OBJPROP_RAY_RIGHT,0);
         }   
           
      for(int d= Bars-1;d>0;d--)
         {        
      double p1= ObjectGetDouble(0,rz+b,OBJPROP_PRICE1); 
         if(p1 >= Low[d] && p1 <= High[d] && iBarShift(NULL,0,ObjectGetInteger(0,rz+b,OBJPROP_TIME)) > d ) 
         {   
            ObjectSet(rz+b,OBJPROP_PRICE2,p1);
            ObjectSet(rz+b,OBJPROP_TIME2,Time[d]);
            ObjectSetString(0,rz+b,OBJPROP_NAME,"touched"+b);

         }          
         }
         }
 
Hgu Gh:

i tried adding break but it would just give undesired results, the code below doesnt works after using it

Edited.

   static datetime lastBarTime = 0;
   datetime currBarTime = Time[0];

   if (currBarTime>lastBarTime)
   {
      Print ("Bars = ", Bars);
      string rz= "RZ";

      for(int a= 1;a<Bars;a++)
      {
         string name = rz+IntegerToString(a);
         {
            if(ObjectFind(0,name)!=0)
            {
               ObjectCreate(0,name,OBJ_TREND,0,Time[a],Low[a],Time[0],Low[a]);
               ObjectSetInteger(0,name,OBJPROP_SELECTABLE,0);
               ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,0);
            }
            else
            {
               ObjectSet(name,OBJPROP_TIME1,Time[a]);
               ObjectSet(name,OBJPROP_TIME2,Time[0]);
               ObjectSet(name,OBJPROP_PRICE1,Low[a]);
               ObjectSet(name,OBJPROP_PRICE2,Low[a]);
            }
         }   
           
         for(int d= a-1;d>0;d--)
         {        
            double p1= ObjectGetDouble(0,name,OBJPROP_PRICE1); 
            if(p1 >= Low[d] && p1 <= High[d]) 
            {   
               ObjectSet(name,OBJPROP_TIME2,Time[d]);
               break;
            }          
         }
      }
      lastBarTime = currBarTime;
   }

You'll get this - 184437 bars within 5 seconds (will be even faster if you didn't insist on using bar number to name your lines):


 
Seng Joo Thio:

Edited.

You'll get this - 184437 bars within 5 seconds (will be even faster if you didn't insist on using bar number to name your lines):


Applause, quickly drawn, well done...thanks

Im a noob at this, hope someday i become like you xD 

Reason: