How to make an indicator not remove the trendlines I have drawn when I change the time frame of the chart

 

Hi guys



I have an indicator that will delete off all the trendlines I have drawn when I change the timeframe of the chart. Is there anyway for it not to remove off the trendline?

 
I think the question should be when DO you want your indicator to remove trendlines. You must have coded it to remove trendlines. So when is it ok. Thats how you need to recode it.
 

ObjectsDeleteAll(Int WINDOW, OBJ_TRENDLINE);

This is a very handy function:

//-----------------------------------------------------------
void DrawVline (color Color, datetime time)
   {//Typical Use: DrawVline(Yellow, Time[i]);
   static int cntr;
   static double PrevVlineTime;
   if (time == PrevVlineTime) return(0);//Still on same bar
      ObjectCreate( "UpLine"+cntr, OBJ_VLINE, 0, time, 0);
      ObjectSet("UpLine"+cntr, OBJPROP_COLOR, Color);
      ObjectSet("UpLine"+cntr, OBJPROP_BACK,true);
      cntr++;
      PrevVlineTime = time;//Store bar time of last drawn line
   return(0);
   }     
//-----------------------------------------------------------  
 

Actually what I want is for the trendlines to remain there. My indicator is alerting me of a certain price bar formation and draws arrows to indicate where is the formation at.


Could that be why it is repainting the screen to remove all trendlines or any objects I place in the chart?


If so, what should I do?

 

so you're manually creating the trendlines? then your indicator is deleting all objects instead of only deleting what it's supposed to delete. and without code to see, it's hard to say exactly how to fix. I can tell you that you need to alter the object deletion portion so that it actually looks at the name of the object and deletes if it matches the name of the arrows like:

if(StringFind(objname,"Arrow")) ObjectDelete(objname);

Reason: