How trendline object coordinate point make static as manual trendline

 

I want to draw trendline on chart,

example I drawl uptrend line ,

it coordinate points need to be static , it mean dont want to move whenever coordinate point value change,because we write the code as follow

void OnTick() {

    int CandleonChart = WindowFirstVisibleBar();
    
    int lowestCandle = iLowest(Symbol(),0,MODE_LOW,CandleonChart,0);
    
    ObjectDelete("LT");
    ObjectCreate(0,"LT",OBJ_TREND,0,Time[lowestCandle],Low[lowestCandle],Time[5],Low[5]);
    ObjectSetInteger(0,"LT",OBJPROP_COLOR,clrRed);
    ObjectSetInteger(0,"LT",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSetInteger(0,"LT",OBJPROP_RAY,true);
    
  

}


this make a uptrendline as picture,


as all we know this two coordinate points are moving as wrote in codes,

I want to be static this coordinate point , So we can call breakout trendline entry, if coordinate points are moving , we cannot get real entry points.

How can do that my friends.

 
Stop deleting and recreating the line each tick.
 
William Roeder #:
Stop deleting and recreating the line each tic
William Roeder #:
Stop deleting and recreating the line each tick.

stop comment if you have no answer .

 
LONNV #: stop comment if you have no answer .

I gave you the answer. I'm not going to code it for you.

 
William Roeder #:

I gave you the answer. I'm not going to code it for you.

thanks you .
 
William Roeder #:

I gave you the answer. I'm not going to code it for you.

so how should edit coordinate point to become static.

 
LONNV #: so how should edit coordinate point to become static.

Exactly as William stated. Don't create and delete the object on every tick. Create the line object only once, then leave it.

 

first determine the trending condition. then draw trend and confirm trend drawn and skip the drawn i.e. confirmed condition..


void OnTick() {

if (!drawn)
 { 
 if (checkcondition())
    {
      // ..... draw
     //
     drawn=true;     
    }
 }
}
 
Mustafa Damgaci #:

first determine the trending condition. then draw trend and confirm trend drawn and skip the drawn i.e. confirmed condition..


here i make one condition that make Downtrend , I not delete this trend ,

 
     int highestCandle = iHighest(Symbol(),0,MODE_HIGH,500,0);
 
    if( High[highestCandle] > High[5] )
 {
    ObjectCreate(0,"HT",OBJ_TREND,0,Time[highestCandle],High[highestCandle],Time[0],High[0]);
    ObjectSetInteger(0,"HT",OBJPROP_COLOR,clrBlue);
    ObjectSetInteger(0,"HT",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSetInteger(0,"HT",OBJPROP_RAY,true);
  } 
       
   

but this downtrend never again appear when next condition meet again.

How can redraw it?

How can I solve this ?

If this is due to object name,  need to set new name whenever meet condition.
how can do it.