Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   Help - Add Toggle On/Off button to a GapFinder indicator (http://www.expert-advisor.com/forum/showthread.php?t=7167)

FT_Trading 14.03.22 15:04

Help - Add Toggle On/Off button to a GapFinder indicator
 
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
https://www.linkpicture.com/q/1_1148.png

This is how it prints gaps on charts
https://www.linkpicture.com/q/1_1149.png

CODE

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



Alle Zeitangaben in WEZ +1. Es ist jetzt 13:20 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum