How to delete visible object only on current timeframe?

 

Hi guys, anyone have ideas about how to delete only visible objects on current timeframe?

I have this code here for delete all objects:

if (ctrl_pressed == false && lparam == 16)  // Shift key pressed
         ctrl_pressed = true;
      else if (ctrl_pressed == true) {
         if (lparam == 68) {         //Shift-D to Delete All Objects
            for(int i = ObjectsTotal() -1; i >=0; i--) {
                  ObjectDelete(ObjectName(i));
            }
            ctrl_pressed = false;
         }
         if (lparam == 70) {         //Shift-F to Delete Trendline
            for(int i = ObjectsTotal() -1; i >=0; i--) {
            string Name1 = ObjectName(i);
               if(StringSubstr(Name1,0,5) == "Trend"){
                  ObjectDelete(Name1);
               }
            }
            ctrl_pressed = false;
         }
}

but I want to delete only the objects or Trendlines that is visible in this Timeframe, e.g. H1. Not objects in H4 or D1. Can someone help me with this? Thanks in advance!

 
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
              urgent help.

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum

  2. Compute the current timeframe bit mask and check if the object has that bit set.
              Visibility of Objects - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
Reason: