Download MetaTrader 5

Clear Objects on Chart from "x" bars back

To add comments, please log in or register
sdoppke
71
sdoppke  
//----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!


SD

whroeder1
14781
whroeder1  
Get the time of the object. get the shift from the time. test.
sdoppke
71
sdoppke  
WHRoeder:
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?



iBarShift

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


ObjectGetTimeByValue

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
   );



whroeder1
14781
whroeder1  
  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?
To add comments, please log in or register