Trying to add mobile notification function to CCI divergence indicator V 1.1

 
Hey Guys, can anyone please help me with the param
//+------------------------------------------------------------------+
//|                                                CCI DIVERGENCE.mq4|
//|                                      Copyright 2022, ISMAIL LEMIN|
//|                                       http://https://www.mql5.com|
//+------------------------------------------------------------------+

//--------------------------FX5 edited by Ismail-----------------------------

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Magenta
#property indicator_color4 DodgerBlue
//----
#define arrowsDisplacement 0.0001
//---- input parameters
extern string separator1 = "*** CCI Settings ***";
extern int    fastEMA = 12;
extern int    slowEMA = 26;
extern int    signalSMA = 9;
extern string separator2 = "*** Indicator Settings ***";
extern bool   drawIndicatorTrendLines = true;
extern bool   drawPriceTrendLines = true;
extern bool   displayAlert = true;
extern bool   Notify = true;  // Added this boolean option 
//---- buffers
double bullishDivergence[];
double bearishDivergence[];
double CCI[];
double signal[];
//----
static datetime lastAlertTime;
static string   indicatorName;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexStyle(3, DRAW_LINE);
//----
   SetIndexBuffer(0, bullishDivergence);
   SetIndexBuffer(1, bearishDivergence);
   SetIndexBuffer(2, CCI);
   SetIndexBuffer(3, signal);
//----
   SetIndexArrow(0, 233);
   SetIndexArrow(1, 234);
//----
   indicatorName = "Divergence(" + fastEMA + ", " +
                   slowEMA + ", " + signalSMA + ")";
   SetIndexDrawBegin(3, signalSMA);
   IndicatorDigits(Digits + 2);
   IndicatorShortName(indicatorName);

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   for(int i = ObjectsTotal() - 1; i >= 0; i--)
     {
      string label = ObjectName(i);
      if(StringSubstr(label, 0, 18) != "CCI_DivergenceLine")
         continue;
      ObjectDelete(label);
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int countedBars = IndicatorCounted();
   if(countedBars < 0)
      countedBars = 0;
   CalculateIndicator(countedBars);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CalculateIndicator(int countedBars)
  {
   for(int i = Bars - countedBars; i >= 0; i--)
     {
      CalculateCCI(i);
      CatchBullishDivergence(i + 2);
      CatchBearishDivergence(i + 2);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CalculateCCI(int i)
  {
   CCI[i] = iCCI(Symbol(),0,12,PRICE_TYPICAL,i);

   signal[i] = iCCI(Symbol(),0,12,PRICE_TYPICAL,i);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CatchBullishDivergence(int shift)
  {
   if(IsIndicatorTrough(shift) == false)
      return;
   int currentTrough = shift;
   int lastTrough = GetIndicatorLastTrough(shift);
//----
   if(CCI[currentTrough] > CCI[lastTrough] &&
      Low[currentTrough] < Low[lastTrough])
     {
      bullishDivergence[currentTrough] = CCI[currentTrough] -
                                         arrowsDisplacement;
      //----
      if(drawPriceTrendLines == true)
         DrawPriceTrendLine(Time[currentTrough], Time[lastTrough],
                            Low[currentTrough],
                            Low[lastTrough], Green, STYLE_SOLID);
      //----
      if(drawIndicatorTrendLines == true)
         DrawIndicatorTrendLine(Time[currentTrough],
                                Time[lastTrough],
                                CCI[currentTrough],
                                CCI[lastTrough],
                                Green, STYLE_SOLID);
      //----
      if(displayAlert == true)
         DisplayAlert("Classical bullish divergence on: ",
                      currentTrough);
      if(Notify == true)
         PushNotification("Classical bullish divergence on: ",
                          currentTrough);
     }
//----
   if(CCI[currentTrough] < CCI[lastTrough] &&
      Low[currentTrough] > Low[lastTrough])
     {
      bullishDivergence[currentTrough] = CCI[currentTrough] -
                                         arrowsDisplacement;
      //----
      if(drawPriceTrendLines == true)
         DrawPriceTrendLine(Time[currentTrough], Time[lastTrough],
                            Low[currentTrough],
                            Low[lastTrough], Green, STYLE_DOT);
      //----
      if(drawIndicatorTrendLines == true)
         DrawIndicatorTrendLine(Time[currentTrough],
                                Time[lastTrough],
                                CCI[currentTrough],
                                CCI[lastTrough],
                                Green, STYLE_DOT);
      //----
      if(displayAlert == true)
         DisplayAlert("Hidden bullish divergence: ",
                      currentTrough);
      if(Notify == true)
         PushNotification("Hidden bullish divergence: ",
                          currentTrough);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CatchBearishDivergence(int shift)
  {
   if(IsIndicatorPeak(shift) == false)
      return;
   int currentPeak = shift;
   int lastPeak = GetIndicatorLastPeak(shift);
//----
   if(CCI[currentPeak] < CCI[lastPeak] &&
      High[currentPeak] > High[lastPeak])
     {
      bearishDivergence[currentPeak] = CCI[currentPeak] +
                                       arrowsDisplacement;

      if(drawPriceTrendLines == true)
         DrawPriceTrendLine(Time[currentPeak], Time[lastPeak],
                            High[currentPeak],
                            High[lastPeak], Red, STYLE_SOLID);

      if(drawIndicatorTrendLines == true)
         DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak],
                                CCI[currentPeak],
                                CCI[lastPeak], Red, STYLE_SOLID);

      if(displayAlert == true)
         DisplayAlert("Classical bearish divergence on: ",
                      currentPeak);
      if(Notify == true)
         PushNotification("Classical bearish divergence on: ",
                          currentPeak);
     }
   if(CCI[currentPeak] > CCI[lastPeak] &&
      High[currentPeak] < High[lastPeak])
     {
      bearishDivergence[currentPeak] = CCI[currentPeak] +
                                       arrowsDisplacement;
      //----
      if(drawPriceTrendLines == true)
         DrawPriceTrendLine(Time[currentPeak], Time[lastPeak],
                            High[currentPeak],
                            High[lastPeak], Red, STYLE_DOT);
      //----
      if(drawIndicatorTrendLines == true)
         DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak],
                                CCI[currentPeak],
                                CCI[lastPeak], Red, STYLE_DOT);
      //----
      if(displayAlert == true)
         DisplayAlert("Reverse bearish divergence on: ",
                      currentPeak);
      if(Notify == true)
         PushNotification("Hidden bearish divergence on: ",
                          currentPeak);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsIndicatorPeak(int shift)
  {
   if(CCI[shift] >= CCI[shift+1] && CCI[shift] > CCI[shift+2] &&
      CCI[shift] > CCI[shift-1])
      return(true);
   else
      return(false);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsIndicatorTrough(int shift)
  {
   if(CCI[shift] <= CCI[shift+1] && CCI[shift] < CCI[shift+2] &&
      CCI[shift] < CCI[shift-1])
      return(true);
   else
      return(false);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetIndicatorLastPeak(int shift)
  {
   for(int i = shift + 5; i < Bars; i++)
     {
      if(signal[i] >= signal[i+1] && signal[i] >= signal[i+2] &&
         signal[i] >= signal[i-1] && signal[i] >= signal[i-2])
        {
         for(int j = i; j < Bars; j++)
           {
            if(CCI[j] >= CCI[j+1] && CCI[j] > CCI[j+2] &&
               CCI[j] >= CCI[j-1] && CCI[j] > CCI[j-2])
               return(j);
           }
        }
     }
   return(-1);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetIndicatorLastTrough(int shift)
  {
   for(int i = shift + 5; i < Bars; i++)
     {
      if(signal[i] <= signal[i+1] && signal[i] <= signal[i+2] &&
         signal[i] <= signal[i-1] && signal[i] <= signal[i-2])
        {
         for(int j = i; j < Bars; j++)
           {
            if(CCI[j] <= CCI[j+1] && CCI[j] < CCI[j+2] &&
               CCI[j] <= CCI[j-1] && CCI[j] < CCI[j-2])
               return(j);
           }
        }
     }
   return(-1);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DisplayAlert(string message, int shift)
  {
   if(shift <= 2 && Time[shift] != lastAlertTime)
     {
      lastAlertTime = Time[shift];
      Alert(message, Symbol(), " , ", Period(), " minutes chart");
     }
  }
//+------------------------------------------------------------------+
void PushNotification(string message, int shift)
  {
   if(shift <= 2 && Time[shift] != lastAlertTime)
     {
      lastAlertTime = Time[shift];
      SendNotification(message, Symbol(), " , ", Period(), " minutes chart"); // I get the error message on this line. Not sure what to use.
     }
  }

//|                                                                  |
//+------------------------------------------------------------------+
void DrawPriceTrendLine(datetime x1, datetime x2, double y1,
                        double y2, color lineColor, double style)
  {
   string label = "CCI_DivergenceLine" + DoubleToStr(x1, 0);
   ObjectDelete(label);
   ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);
   ObjectSet(label, OBJPROP_RAY, 0);
   ObjectSet(label, OBJPROP_COLOR, lineColor);
   ObjectSet(label, OBJPROP_STYLE, style);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DrawIndicatorTrendLine(datetime x1, datetime x2, double y1,
                            double y2, color lineColor, double style)
  {
   int indicatorWindow = WindowFind(indicatorName);
   if(indicatorWindow < 0)
      return;
   string label = "CCI_DivergenceLine_" + DoubleToStr(x1, 0);
   ObjectDelete(label);
   ObjectCreate(label, OBJ_TREND, indicatorWindow, x1, y1, x2, y2,
                0, 0);
   ObjectSet(label, OBJPROP_RAY, 0);
   ObjectSet(label, OBJPROP_COLOR, lineColor);
   ObjectSet(label, OBJPROP_STYLE, style);
  }
//+------------------------------------------------------------------+
void Comments()
  {
   Comment("Get it automated");

   return;
  }


//+------------------------------------------------------------------+

eters for the SendNotification function? I just added an external Boolean option for push notifications and also added a few lines of codes for that purpose alongside the Alerts. When I compile the code, I get "SendNotification  - wrong parameters count. I have commented out the line that give error plus the additional boolean option. I will really be grateful for any assistance to get the notifications option done. 
 
Ismail Lemin:
Hey Guys, can anyone please help me with the param
eters for the SendNotification function? I just added an external Boolean option for push notifications and also added a few lines of codes for that purpose alongside the Alerts. When I compile the code, I get "SendNotification  - wrong parameters count. I have commented out the line that give error plus the additional boolean option. I will really be grateful for any assistance to get the notifications option done. 
SendNotification(message, Symbol(), " , ", Period(), " minutes chart"); // I get the error message on this line. Not sure what to use.

I think that you will find that the compiler interprets the commas as separate paramenters.

You can use commas in a Print() but not in SendNotification().

Use + instead of , or prepare the text previously

message+=Symbol()+" , "+(string) Period()+ " minutes chart");
 
Keith Watford #:

I think that you will find that the compiler interprets the commas as separate paramenters.

You can use commas in a Print() but not in SendNotification().

Use + instead of , or prepare the text previously

Thanks a lot Keith it did work. No errors now on the code. I will keep practicing on more codes to try and improve my knowledge on coding. 
 
Ismail Lemin #:
Thanks a lot Keith it did work. No errors now on the code. I will keep practicing on more codes to try and improve my knowledge on coding. 

You're welcome.
As an aside, I think that it is better to actually print the time-frame instead of using Period().

   ENUM_TIMEFRAMES tf=(ENUM_TIMEFRAMES)Period();
   string tf_string=EnumToString(tf);
   message+=Symbol()+" , "+tf_string;

or you can insert it straight into the message in one step

 message+=Symbol()+" , "+EnumToString((ENUM_TIMEFRAMES)Period());
 
Keith Watford #:

You're welcome.
As an aside, I think that it is better to actually print the time-frame instead of using Period().

or you can insert it straight into the message in one step

That's actually better to have timeframe than the period. I will add it today when I get home from work. Thanks again for helping me out. 
 
Ismail Lemin #: That's actually better to have timeframe than the period. I will add it today when I get home from work. Thanks again for helping me out. 

It is actually better to write self-documenting code by writing a function.
          Need some help with some MT5 code - MT5 - Expert Advisors and Automated Trading - MQL5 programming forum (2018)

 
Keith Watford #:

You're welcome.
As an aside, I think that it is better to actually print the time-frame instead of using Period().

or you can insert it straight into the message in one step

Hey Keith I did manage to change the change the line to have the period() function and it works perfectly. I faced a similar problem when editing the SendNotification() function on a small MA Crossover indicator. I tried to replace commas with + but I get errors on the code. I can't figure out what am doing wrong. Please bare with me as am still far from good at programming.

//+------------------------------------------------------------------+
//|                                         EMA-Crossover_Signal.mq4 |
//|         Copyright © 2005, Jason Robinson (jnrtrading)            |
//|                   http://www.jnrtading.co.uk                     |
//+------------------------------------------------------------------+

/*
  +------------------------------------------------------------------+
  | Allows you to enter two ema periods and it will then show you at |
  | Which point they crossed over. It is more useful on the shorter   |
  | periods that get obscured by the bars / candlesticks and when    |
  | the zoom level is out. Also allows you then to remove the emas   |
  | from the chart. (emas are initially set at 5 and 6)              |
  +------------------------------------------------------------------+
*/   
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)"
#property link      "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkGreen
#property indicator_color2 FireBrick

double CrossUp[];
double CrossDown[];
extern int FasterEMA = 9;
extern int SlowerEMA = 20;
extern bool SoundON=true;
extern bool Notify = true;
double alertTag;
double control=2147483647;
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY,1);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY,1);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter;
   double Range, AvgRange;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;
   
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;
       
      fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

      slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);
      
      if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) {
         CrossUp[i] = Low[i] - Range*0.5;
      }
      else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) {
          CrossDown[i] = High[i] + Range*0.5;
      }
        if (SoundON==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){
         Alert("EMA Cross Trend going Down on ",Symbol()," ",Period());
         alertTag = Time[0];
      }
        if (SoundON==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){
         Alert("EMA Cross Trend going Up on ",Symbol()," ",Period());
         alertTag = Time[0];
        } 
       
        if (Notify==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){
          SendNotification("EMA Cross Trend going Down on ",Symbol()," ",Period()); //wrong parameters
          alertTag = Time[0];
        }
      if  (Notify==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){
          SendNotification("EMA Cross Trend going Up on ",Symbol()," ",Period()); //wrong parameters
          alertTag = Time[0];
         
         //SendNotification(message+=Symbol()+" , "+(string) Period()+ " minutes chart"); 
         // Tried to use the above example from last time but am still getting errors.
        }
      
  }
   return(0);
}
 
Ismail Lemin #:

Hey Keith I did manage to change the change the line to have the period() function and it works perfectly. I faced a similar problem when editing the SendNotification() function on a small MA Crossover indicator. I tried to replace commas with + but I get errors on the code. I can't figure out what am doing wrong. Please bare with me as am still far from good at programming.

         //SendNotification(message+=Symbol()+" , "+(string) Period()+ " minutes chart"); 
         // Tried to use the above example from last time but am still getting errors.

I don't see that you have declared the variable message anywhere in your code

         SendNotification("EMA Cross Trend going Up on "+Symbol()+" , "+(string) Period()+ " minutes chart");

Should work.

 
Keith Watford #:

I don't see that you have declared the variable message anywhere in your code

Should work.

Hey Keith, just got back to editing the SendNotification line but unfortunately no notification is being sent to phone despite no errors on the code when compling. I even used the enumerate option without errors but no notification is being sent. There is something am missing, please help me out once again.

//+------------------------------------------------------------------+
//|                                         EMA-Crossover_Signal.mq4 |
//|         Copyright © 2005, Jason Robinson (jnrtrading)            |
//|                   http://www.jnrtading.co.uk                     |
//+------------------------------------------------------------------+

/*
  +------------------------------------------------------------------+
  | Allows you to enter two ema periods and it will then show you at |
  | Which point they crossed over. It is more useful on the shorter   |
  | periods that get obscured by the bars / candlesticks and when    |
  | the zoom level is out. Also allows you then to remove the emas   |
  | from the chart. (emas are initially set at 5 and 6)              |
  +------------------------------------------------------------------+
*/   
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)"
#property link      "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkGreen
#property indicator_color2 FireBrick

double CrossUp[];
double CrossDown[];
extern int FasterEMA = 9;
extern int SlowerEMA = 20;
extern bool SoundON=true;
extern bool Notify = true;
double alertTag;
double control=2147483647;
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY,1);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY,1);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter;
   double Range, AvgRange;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;
   
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;
       
      fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

      slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);
      
      if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) {
         CrossUp[i] = Low[i] - Range*0.5;
      }
      else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) {
          CrossDown[i] = High[i] + Range*0.5;
      }
        if (SoundON==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){
         Alert("EMA Cross Trend going Down on ",Symbol()," "+EnumToString((ENUM_TIMEFRAMES)Period()));
         alertTag = Time[0];
      }
        if (SoundON==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){
         Alert("EMA Cross Trend going Up on ",Symbol()," "+EnumToString((ENUM_TIMEFRAMES)Period()));
         alertTag = Time[0];
        } 
       
        if (Notify==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){
          SendNotification("EMA Cross Trend going Down on "+Symbol()+" , "+EnumToString((ENUM_TIMEFRAMES)Period()));
        }//Not getting any notifications
      if  (Notify==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){
          SendNotification("EMA Cross Trend going Up on "+Symbol()+", "+EnumToString((ENUM_TIMEFRAMES)Period()));                
        } // Not getting any notifications
      
  }
   return(0);
}
 
Ismail Lemin #:

Hey Keith, just got back to editing the SendNotification line but unfortunately no notification is being sent to phone despite no errors on the code when compling. I even used the enumerate option without errors but no notification is being sent. There is something am missing, please help me out once again.

Go through your code and think about what is happening with the variable alertTag.

 
Keith Watford #:

Go through your code and think about what is happening with the variable alertTag.

I had tweaked with alertTag variable having it added on the line and removing it but still did not get notification. I also see it's at the start of the code as a static variable. The variable is also being used in the If statements to check if the conditions are all true (&&) for it to send notification or alert.