What's new

General Add Toggle On/Off button to a GapFinder indicator

cortyk

Member
Hi Guys,
Could someone add an ON/OFF button on this gap finder indicator I've recently modified?
I'm an amateur noobie programmer and I can only code basic things and this is getting pretty challenging for me.
I've tried to integrate and modify part of other codes with buttons template but no way.

This are the indicators inputs which are customizable
1.png
This is how it prints gaps on charts
2.png
Code:
#property indicator_chart_window
#property indicator_buffers 1
#property description "Automatically render boxes for liquidity gaps "
#property indicator_color1 Black

extern double Gap_Size_Minimum = 100;
extern int ExtendBars = 1000;
extern int    History = 1000;
extern color Gap_Up = Aqua;
extern color Gap_Down = Tomato;
input ENUM_LINE_STYLE Rectangle_Style = STYLE_SOLID;

double Pip;
int init()
  {
    Pip = Point;
   if(Digits==3 || Digits==5) Pip = 10*Point;
   return(0);
  }

int deinit()
  {
    string ObjName;
    for(int i = ObjectsTotal()-1; i>=0; i--)
    {
      ObjName = ObjectName(i);
      if(StringFind(ObjName,"liquidity_gaps",0)>=0)
        ObjectDelete(ObjName);
    }
    return(0);
  }

int start()
  {
   int i, limit, counted_bars=IndicatorCounted();
   limit = MathMin(History,Bars-counted_bars-1);
   string ObjName;
   for(i=limit; i>=0; i--)
   {
     if(i>Bars-2) continue;
     if(MathAbs(Open[i]-Close[i+1]) > Gap_Size_Minimum*Pip)
     {
       ObjName = "liquidity_gaps_Up_"+Time[i];
       color ObjColor;
       if(Open[i] > Close[i+1]) ObjColor = Gap_Up;
       else ObjColor = Gap_Down;
       if(ObjectFind(ObjName)<0)
       { 
         ObjectCreate(ObjName,OBJ_RECTANGLE,0,Time[i+1],Close[i+1],Time[i],Open[i]);
         ObjectSet(ObjName,OBJPROP_BACK,0);         
         ObjectSet(ObjName,OBJPROP_COLOR,ObjColor);                 
         ObjectSet(ObjName,OBJPROP_STYLE,Rectangle_Style);
       }
     }
    
     //datetime thistime = Time[i];     
     int ib = i+ExtendBars;
     while(ib>=0)
    
     {
       ObjName = "liquidity_gaps_Up_"+Time[ib];
       if(ObjectFind(ObjName)>=0)
       {
         double pr2 = ObjectGet(ObjName,OBJPROP_PRICE2);
         double pr1 = ObjectGet(ObjName,OBJPROP_PRICE2);
         ObjectSet(ObjName,OBJPROP_TIME2,Time[i]);
         ObjectSet(ObjName,OBJPROP_PRICE2,pr2);
       }
       ib--;
     }
   }
   return(0);
  }

Thanks in advance for you kind help
 

Attachments

  • GapsFinder.mq4
    3.9 KB · Views: 3

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

Users Who Are Viewing This Thread (Total: 1, Members: 0, Guests: 1)

Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock    No Thanks