Notification and Alerts Interval for Supply Indicator

 

Hey guys, hope everyone is having a good week and closing the week strong. 

I need help in editing notifications and alerts interval for  MT5 shved supply and demand indicator. I copied the lines from the mql4 version on the code, but commented them out.  Details in Line 39 and 273. I need it to at least have a delay of 2 hours notifications or terminal alerts once it hit a support or resistance level. Would truly appreciate any help. 

Thanks in advance

/+------------------------------------------------------------------+
//|                             shved_supply_and_demand_v1.5.mq5     |
//|                      MQL5 version of Shved Supply and Demand     |
//|                                         Behzad.mvr@gmail.com     |
//+------------------------------------------------------------------+
// v1.2: History mode added. Set "historyMode" parameter to true then "double click" on any point in price chart to see Support and Resistance zones in that point.
// v1.3: Added parameter for sending notification to mobile phone when price entering S/R zones
// v1.4: Fixed Sup. & Res. labels in history mode.
// v1.5: Added Timeframe option to show S/R zones of a timeframe on other timeframes.
// v1.6: Optimization in finding the broken zones.
// v1.6: Reorganizing input parameters and deleting the unused codes.
// v1.6: Added prefix parameter, now you can add multiple instance of indicator to the chart by changing the prefix.
// v1.6: Fixed array out of range error when showing zones of a timeframe on other timeframes.
// v1.7: Buffers added for data window to show the strength of support and resistance zones and the type of zone if price is inside a zone.
#property indicator_chart_window
#property indicator_buffers 11
#property indicator_plots   11

input ENUM_TIMEFRAMES      Timeframe = PERIOD_CURRENT;         // Timeframe
input int                  BackLimit = 1000;                   // Back Limit
input bool                 HistoryMode = true;                // History Mode (with double click)

input string               zone_settings = "--- Zone Settings ---";
input bool                 zone_show_weak = true;             // Show Weak Zones
input bool                 zone_show_untested = true;          // Show Untested Zones
input bool                 zone_show_turncoat = true;          // Show Broken Zones
input double               zone_fuzzfactor = 0.85;             // Zone ATR Factor
input bool                 zone_merge = true;                  // Zone Merge
input bool                 zone_extend = true;                 // Zone Extend
input double               fractal_fast_factor = 3.0;          // Fractal Fast Factor
input double               fractal_slow_factor = 6.0;          // Fractal slow Factor

input string               alert_settings= "--- Alert Settings ---";
input bool                 zone_show_alerts  = true;        // Trigger alert when entering a zone
input bool                 zone_alert_popups = true;         // Show alert window
input bool                 zone_alert_sounds = true;         // Play alert sound
input bool                 zone_send_notification = true;   // Send notification when entering a zone
input int                  zone_alert_waitseconds = 300;     // Delay between alerts (seconds)

input string NotiMobile="/////////////////////////////////////////////////";
//input bool New_zone_is_created  = false; //New zone is created
input bool price_hit_the_zone  = true; // price hit the zone
input bool Userinterval_time = true;
input int Interval_time = 120; // Interval time per Min

input string               drawing_settings = "--- Drawing Settings ---";
input string               string_prefix = "SRRR";             // Change prefix to add multiple indicators to chart
input bool                 zone_solid = true;                  // Fill zone with color
input int                  zone_linewidth = 1;                 // Zone border width
input ENUM_LINE_STYLE      zone_style = STYLE_SOLID;           // Zone border style
input bool                 zone_show_info = false;              // Show info labels
input int                  zone_label_shift = 10;              // Info label shift
input string               sup_name = "Sup";                   // Support Name
input string               res_name = "Res";                   // Resistance Name
input string               test_name = "Retests";              // Retest Name
input int                  Text_size = 8;                      // Text Size
input string               Text_font = "Courier New";          // Text Font
input color                Text_color = clrBlack;              // Text Color
input color color_support_weak     = clrDarkOliveGreen;         // Color for weak support zone
input color color_support_untested = clrDarkOliveGreen;              // Color for untested support zone
input color color_support_verified = clrDarkOliveGreen;                 // Color for verified support zone
input color color_support_proven   = clrDarkOliveGreen;             // Color for proven support zone
input color color_support_turncoat = clrMidnightBlue;             // Color for turncoat(broken) support zone
input color color_resist_weak      = clrMaroon;                // Color for weak resistance zone
input color color_resist_untested  = clrMaroon;                // Color for untested resistance zone
input color color_resist_verified  = clrMaroon;               // Color for verified resistance zone
input color color_resist_proven    = clrMaroon;                   // Color for proven resistance zone
input color color_resist_turncoat  = clrMidnightBlue;            // Color for broken resistance zone

ENUM_TIMEFRAMES timeframe;
double FastDnPts[],FastUpPts[];
double SlowDnPts[],SlowUpPts[];

double zone_hi[1000],zone_lo[1000];
int    zone_start[1000],zone_hits[1000],zone_type[1000],zone_strength[1000],zone_count=0;
bool   zone_turn[1000];

#define ZONE_SUPPORT 1
#define ZONE_RESIST  2

#define ZONE_WEAK      0
#define ZONE_TURNCOAT  1
#define ZONE_UNTESTED  2
#define ZONE_VERIFIED  3
#define ZONE_PROVEN    4

#define UP_POINT 1
#define DN_POINT -1

int time_offset=0;

double ner_lo_zone_P1[];
double ner_lo_zone_P2[];
double ner_hi_zone_P1[];
double ner_hi_zone_P2[];
double ner_hi_zone_strength[];
double ner_lo_zone_strength[];
double ner_price_inside_zone[];
int iATR_handle;
double ATR[];
int cnt=0;
bool try_again=false;
string comment="Updating Chart...";
string prefix;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   prefix=string_prefix+"#";
   if(Timeframe==PERIOD_CURRENT)
      timeframe=Period();
   else
      timeframe=Timeframe;
   iATR_handle=iATR(NULL,timeframe,7);
   SetIndexBuffer(0,SlowDnPts,INDICATOR_DATA);
   SetIndexBuffer(1,SlowUpPts,INDICATOR_DATA);
   SetIndexBuffer(2,FastDnPts,INDICATOR_DATA);
   SetIndexBuffer(3,FastUpPts,INDICATOR_DATA);
   PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_NONE);
   SetIndexBuffer(4,ner_hi_zone_P1,INDICATOR_DATA);
   SetIndexBuffer(5,ner_hi_zone_P2,INDICATOR_DATA);
   SetIndexBuffer(6,ner_lo_zone_P1,INDICATOR_DATA);
   SetIndexBuffer(7,ner_lo_zone_P2,INDICATOR_DATA);
   SetIndexBuffer(8,ner_hi_zone_strength,INDICATOR_DATA);
   SetIndexBuffer(9,ner_lo_zone_strength,INDICATOR_DATA);
   SetIndexBuffer(10,ner_price_inside_zone,INDICATOR_DATA);
   PlotIndexSetInteger(4,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(5,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(6,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(7,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(8,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(9,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetInteger(10,PLOT_DRAW_TYPE,DRAW_NONE);
   PlotIndexSetString(4,PLOT_LABEL,"Resistant Zone High");
   PlotIndexSetString(5,PLOT_LABEL,"Resistant Zone Low");
   PlotIndexSetString(6,PLOT_LABEL,"Support Zone High");
   PlotIndexSetString(7,PLOT_LABEL,"Support Zone Low");
   PlotIndexSetString(8,PLOT_LABEL,"Resistant Zone Strength");
   PlotIndexSetString(9,PLOT_LABEL,"Support Zone Strength");
   PlotIndexSetString(10,PLOT_LABEL,"Price Inside Zone");
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(7,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(8,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(9,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(10,PLOT_EMPTY_VALUE,0);
   ArraySetAsSeries(SlowDnPts,true);
   ArraySetAsSeries(SlowUpPts,true);
   ArraySetAsSeries(FastDnPts,true);
   ArraySetAsSeries(FastUpPts,true);
   ArraySetAsSeries(ner_hi_zone_P1,true);
   ArraySetAsSeries(ner_hi_zone_P2,true);
   ArraySetAsSeries(ner_lo_zone_P1,true);
   ArraySetAsSeries(ner_lo_zone_P2,true);
   ArraySetAsSeries(ner_hi_zone_strength,true);
   ArraySetAsSeries(ner_lo_zone_strength,true);
   ArraySetAsSeries(ner_price_inside_zone,true);
   
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   DeleteZones();
   if(StringFind(ChartGetString(0,CHART_COMMENT),comment)>=0)
      Comment("");
   ChartRedraw();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   if(NewBar()==true || (timeframe!=PERIOD_CURRENT && try_again==true))
     {
      int old_zone_count=zone_count;
      FastFractals();
      SlowFractals();
      DeleteZones();
      FindZones();
      DrawZones();
      if(zone_show_info==true)
        {
         showLabels();
        }
     }
   CheckAlerts();
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CheckAlerts()
  {
   if(zone_show_alerts==false && zone_send_notification==false)
      return;
   datetime Time[];
   if(CopyTime(Symbol(),timeframe,0,1,Time)==-1)
      return;
   ArraySetAsSeries(Time,true);
   static int lastalert;
   if(Time[0]-lastalert>zone_alert_waitseconds)
      if(CheckEntryAlerts()==true)
         lastalert=int(Time[0]);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

bool CheckEntryAlerts()
  {
   double Close[];
   ArraySetAsSeries(Close,true);
   CopyClose(Symbol(),timeframe,0,1,Close);
// check for entries
   for(int i=0; i<zone_count; i++)
     {
      if(zone_strength[i]==ZONE_WEAK && zone_show_weak==false)
         continue;
      if(zone_strength[i]==ZONE_UNTESTED && zone_show_untested==false)
         continue;
      if(zone_strength[i]==ZONE_TURNCOAT && zone_show_turncoat==false)
         continue;
      if(Close[0]>=zone_lo[i] && Close[0]<zone_hi[i])
        {
         if(zone_show_alerts==true)
           {
            if(zone_alert_popups==true)
              {
               if(zone_type[i]==ZONE_SUPPORT)
                  Alert(Symbol()+" "+TFTS(timeframe)+": Support Zone Hit.");
               else
                  Alert(Symbol()+" "+TFTS(timeframe)+": Resistance Zone Hit.");
              }
            if(zone_alert_sounds==true)
               PlaySound("alert.wav");
           }
         if(zone_send_notification==true)
           {
            if(zone_type[i]==ZONE_SUPPORT)
               SendNotification(Symbol()+" "+TFTS(timeframe)+": Support Zone Hit.");
            else
               SendNotification(Symbol()+" "+TFTS(timeframe)+": Resistance Zone Hit.");
           }
         return(true);
        }
     }
   return(false);
  }


// ADDED THIS LINES OF CODE FROM THE MQL4 VERSION OF THE INDICATOR.
/*
bool CheckEntryAlerts1()
  {
// check for entries

   for(int i=0; i<zone_count; i++)
     {
      if((TimeCurrent()>datee1 + Interval_time*120)||Userinterval_time==false)
        {
         if(Close[0]>=zone_lo[i] && Close[0]<zone_hi[i])
           {
            if(price_hit_the_zone)
              {
               string date = TimeToString(TimeCurrent());
               string  message1 = Symbol()+TimeFrameToString(Period())+" : SUPPORT HIT    " +DoubleToString(Close[0],Digits)+ "   " +date;
               string  message2 = Symbol()+TimeFrameToString(Period())+" : RESISTANCE HIT    "+DoubleToString(Close[0],Digits)+ "   "+date;

               if(zone_type[i]==ZONE_SUPPORT)
                  SendNotification(message1);
               else
                  SendNotification(message2);
                           datee1 =TimeCurrent();
              }

            return(true);
           }

        }
     }

   return(false);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CheckEntryAlerts()
  {
// check for entries
   for(int i=0; i<zone_count; i++)
     {
      if((TimeCurrent()>datee + Interval_time*120)||Userinterval_time==false)
        {
         if(Close[0]>=zone_lo[i] && Close[0]<zone_hi[i])
           {
            if(zone_show_alerts==true)
              {
               if(zone_alert_popups==true)
                 {
                  if(zone_type[i]==ZONE_SUPPORT)
                     Alert(Symbol()+TimeFrameToString(Period())+": Support Zone Hit "+DoubleToString(Close[0],Digits));
                  else
                     Alert(Symbol()+TimeFrameToString(Period())+": Resistance Zone Hit "+DoubleToString(Close[0],Digits));
                              datee =TimeCurrent();

                 }

               if(zone_alert_sounds==true)
                  PlaySound("alert_wav");
              }

            return(true);
           }
        }
     }
   return(false);
  }
  */
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
 
i recommend that you look in codebase. search this website for terms such as "alerts". There are several that I have copied to use for my own purposes -- from there(codebase).
 
Michael Charles Schefe #:
i recommend that you look in codebase. search this website for terms such as "alerts". There are several that I have copied to use for my own purposes -- from there(codebase).
Hi Michael hope you are doing well. I really have searched and tried to edit the lines but I can't get it right because of my coding level. Those 2 lines mentioned are the my issue there. I could really use your help please. Am totally stuck on that one. 
 
Ismail Lemin #:
Hi Michael hope you are doing well. I really have searched and tried to edit the lines but I can't get it right because of my coding level. Those 2 lines mentioned are the my issue there. I could really use your help please. Am totally stuck on that one. 

busy right now, maybe later.

did you send a request msg to the author?

 
Michael Charles Schefe #:

busy right now, maybe later.

did you send a request msg to the author?

No I haven't the author is nowhere to be found. Safe journey on your side. If you get a chnace please.