How do I get a single notification for this indicator? so he sends a notification every second. because?

 
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

datetime timeBar=0;
bool isNewBar;


int start()
  {
//--- indicator buffers mapping
 {
   isNewBar = (Time[0]!=timeBar);
   timeBar = Time[0];

   // only Alert for your chart TimeFrame

}  
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---


double mc1=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
double mc2=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); 
double mc01=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); 
double mc02=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0); 




if(mc1<mc2&&mc01>mc02)
 
 
  if(isNewBar)SendNotification(Symbol()+" TF:"+IntegerToString(Period())+" "+" buy: ");
  
 

  
  
  
if(mc1>mc2&&mc01<mc02) 
  if(isNewBar)SendNotification(Symbol()+" TF:"+IntegerToString(Period())+" "+"short: ");



   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

 

Try this:

//+------------------------------------------------------------------+
//+                                       isNewBar MACD Notification +
//+------------------------------------------------------------------+

#property copyright "Copyright 2018, МегаКурец Software Corp."

#property indicator_chart_window

datetime timeBar;
bool isNewBar;

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(Time[0]!=timeBar) isNewBar=true;
   else isNewBar=false;

   double mc1=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
   double mc2=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); 
   double mc01=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); 
   double mc02=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0); 

   if(isNewBar)
     {
      if(mc1<mc2&&mc01>mc02) SendNotification(Symbol()+" TF:"+IntegerToString(Period())+" "+" buy: ");
      if(mc1>mc2&&mc01<mc02) SendNotification(Symbol()+" TF:"+IntegerToString(Period())+" "+"short: ");
      timeBar = Time[0];
     }

   return(rates_total);
  }

//+------------------------------------------------------------------+
 
kypa:

Try this:

if(Time[0]!=timeBar) isNewBar;  

on this line he tells   me: expression has no effect. in the same way this code sends me notifications every second
 
  1. int start(){
       isNewBar = (Time[0]!=timeBar);
       timeBar = Time[0];
       return(INIT_SUCCEEDED);
      }
    int OnCalculate(const int rates_total,
    Use the old init/start or the new OnInit/OnCalculate. You can not use both.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

  2. What do you think if(condition) true; possibly does? Nothing (expression has no effect.)

  3. if(Time[0]!=timeBar) isNewBar=true;
       else isNewBar=false;
    Simplified: isNewBar = Time[0]!=timeBar;
              Increase Order after stoploss - MQL4 and MetaTrader 4 - MQL4 programming forum № 3

 
yes I understand, thank you so much to you two
 
kypa:

Try this:

mt5