Clear Objects on Chart from "x" bars back

Back to topics list To post a new topic, please log in or register
sdoppke 2015.09.09 18:47
//----delete objects
// {
//   for(int z=ObjectsTotal()-1; z>20; z--) {
//      ObjectDelete(ObjectName(z));
//   }
//   Comment("");
//   return(0);
//  }
//----delete objects

Hi everyone, I have been searching with no luck for a way to clear a chart from "x" bars back.  So for example any objects that are older than 50 bars get deleted. I am thinking this code could be modified to do that, it clears the whole chart in it's current state.

Would anyone have any ideas on what to change here?

Thanks for any help!


WHRoeder 2015.09.09 20:44 #
Get the time of the object. get the shift from the time. test.
sdoppke 2015.09.10 21:15 #
Get the time of the object. get the shift from the time. test.
WhRoeder I get that your trying to teach me to fish (appreciate that).  I am not quite following yet.  Are you referring to below?  Would you mind elaborating a bit more to get me off an running?


Search for a bar by its time. The function returns the index of the bar which covers the specified time.

int  iBarShift(
   string           symbol,          // symbol
   int              timeframe,       // timeframe
   datetime         time,            // time
   bool             exact=false      // mode


The function returns the time value for the specified price value of the specified object.

datetime  ObjectGetTimeByValue(
   string   object_name,   // object name
   double   value,         // price
   int      line_id=0      // line identifier

WHRoeder 2015.09.11 00:58 #
  1. ObjectGetTimeByValue - MQL4 Documentation is used (on all the object types listed) because they have multiple times (Trendline start/end.) and you need a time between them.
  2. If you just need the start time/end time why would you need that?

Back to topics list  

To add comments, please log in or register