ADX Push Notification

 

Hello, can anyone fix this code?  I'm trying to change it from send email alert to send a push notification.  Thanks!

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

//---- input parameters
extern int ADXperiod =14;
extern int ADXLevel  =20;

extern int CountBars=350;
extern bool MainSignalAlert=true;
extern bool MainSignalEmail=false;
extern bool ADXDIMinusCrossingAlert=false;
extern bool ADXDIPlusCrossingAlert=false;
extern bool DIMinusADXCrossingAlert=false;
extern bool DIPlusADXCrossingAlert=false;
extern bool ADXLevelCrossingAlert=false;
extern bool ADXDIMinusCrossingEmail=false;
extern bool ADXDIPlusCrossingEmail=false;
extern bool DIMinusADXCrossingEmail=false;
extern bool DIPlusADXCrossingEmail=false;
extern bool ADXLevelCrossingEmail=false;
///
extern bool ADXSnapMainAlert=false;
extern bool ADXSnapPlusAlert=false;
extern bool ADXSnapMinusAlert=false;
extern bool ADXSnapMainEmail=false;
extern bool ADXSnapPlusEmail=false;
extern bool ADXSnapMinusEmail=false;
///

extern int SignalGap=10;

extern int PointsOfSnap = 15;  

//---- buffers
double val1[];
double val2[];

datetime ADXLineLastAlert=EMPTY_VALUE;
datetime ADXPlusLastAlert=EMPTY_VALUE;
datetime ADXMinusLastAlert=EMPTY_VALUE;
datetime PlusADXLastAlert=EMPTY_VALUE;
datetime MinusADXLastAlert=EMPTY_VALUE;
datetime ADXLevelLastAlert=EMPTY_VALUE;

datetime ADXSnapMainLastAlert=EMPTY_VALUE;
datetime ADXSnapPlusLastAlert=EMPTY_VALUE;
datetime ADXSnapMinusLastAlert=EMPTY_VALUE;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator line
   IndicatorBuffers(2);   
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,108);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,108);
   if(IsConnected())
     {
      ADXLineLastAlert=TimeCurrent();
      ADXPlusLastAlert=ADXLineLastAlert;
      ADXMinusLastAlert=ADXLineLastAlert;
      PlusADXLastAlert=ADXLineLastAlert;
      MinusADXLastAlert=ADXLineLastAlert;
      ADXLevelLastAlert=ADXLineLastAlert;
      
      ADXSnapMainLastAlert=ADXLineLastAlert;
      ADXSnapPlusLastAlert=ADXLineLastAlert;
      ADXSnapMinusLastAlert=ADXLineLastAlert;
     }
   
//----
   return(0);
  }

int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+
//| ADX Crossing                                                     |
//+------------------------------------------------------------------+
int start()
  {

   double b4main,nowmain,b4plusdi,nowplusdi,b4minusdi,nowminusdi, b4b4main,b4b4plusdi,b4b4minusdi ;
   
   int counted_bars=IndicatorCounted();

   if(!IsConnected())
     {
      ADXLineLastAlert=EMPTY_VALUE;
      ADXPlusLastAlert=EMPTY_VALUE;
      ADXMinusLastAlert=EMPTY_VALUE;
      PlusADXLastAlert=EMPTY_VALUE;
      MinusADXLastAlert=EMPTY_VALUE;
      ADXLevelLastAlert=EMPTY_VALUE;
      
      ADXSnapMainLastAlert=EMPTY_VALUE;
      ADXSnapPlusLastAlert=EMPTY_VALUE;
      ADXSnapMinusLastAlert=EMPTY_VALUE;
     }
   else
     if(ADXLineLastAlert==EMPTY_VALUE)
       {
        ADXLineLastAlert=TimeCurrent();
        ADXPlusLastAlert=ADXLineLastAlert;
        ADXMinusLastAlert=ADXLineLastAlert;
        PlusADXLastAlert=ADXLineLastAlert;
        MinusADXLastAlert=ADXLineLastAlert;
        ADXLevelLastAlert=ADXLineLastAlert;  
        
        ADXSnapMainLastAlert=ADXLineLastAlert;
        ADXSnapPlusLastAlert=ADXLineLastAlert;
        ADXSnapMinusLastAlert=ADXLineLastAlert;
       }


   //---- check for possible errors
   if(counted_bars<0) return(-1);

   int limit=Bars-counted_bars;
   if(limit>CountBars)
     limit=CountBars;

   for (int shift = limit; shift>=0; shift--)
   {
      b4main=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_MAIN,shift+1);
       nowmain=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_MAIN,shift);
       b4plusdi=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_PLUSDI,shift+1);
       nowplusdi=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_PLUSDI,shift);
       b4minusdi=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_MINUSDI,shift+1);
       nowminusdi=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_MINUSDI,shift);
       ////===òóò íà÷àë
       b4b4main=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_MAIN,shift+2);
       b4b4plusdi=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_PLUSDI,shift+2);
       b4b4minusdi=iADX(NULL,0,ADXperiod,PRICE_CLOSE,MODE_MINUSDI,shift+2);
      
      if (b4plusdi<b4minusdi && nowplusdi>nowminusdi && nowmain>ADXLevel)//crossing condition1
      {
         
          val1[shift]=Low[shift]-SignalGap*Point;
          if((ADXLineLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(MainSignalAlert)
               Alert("BUY signal at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(MainSignalEmail)
               SendNotification("ADX Line Cross Buy signal","BUY signal at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXLineLastAlert=Time[0];
            }
         
      }
      if (b4plusdi>b4minusdi && nowplusdi<nowminusdi && nowmain>ADXLevel)
      {
      
          val2[shift]=High[shift]+SignalGap*Point;         
          if((ADXLineLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(MainSignalAlert)
               Alert("Sell signal at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(MainSignalEmail)
               SendNotification("ADX Line Cross Sell signal","Sell signal at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXLineLastAlert=Time[0];
            }
      }
      
      
      if (b4plusdi<b4main && nowplusdi>nowmain)
      {
         
          if((PlusADXLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(DIPlusADXCrossingAlert)
               Alert("+D crossed ADX at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(DIPlusADXCrossingEmail)
               SendNotification("ADX Line Cross signal +D>ADX","+D crossed ADX at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             PlusADXLastAlert=Time[0];
            }
      }
      if(b4plusdi>b4main && nowplusdi<nowmain)
      {         
          if((ADXPlusLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(ADXDIPlusCrossingAlert)
               Alert("ADX crossed +D at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(ADXDIPlusCrossingEmail)
               SendNotification("ADX Line Cross ADX>+D","ADX crossed +D at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXPlusLastAlert=Time[0];
            }
      }
      if (b4minusdi>b4main && nowminusdi<nowmain)
      {
         if((ADXMinusLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(ADXDIMinusCrossingAlert)
               Alert("ADX crossed -D at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(ADXDIMinusCrossingEmail)
               SendNotification("ADX Line Cross ADX>-D","ADX crossed -D at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXMinusLastAlert=Time[0];
            }
      }
      if(b4minusdi<b4main && nowminusdi>nowmain)
      {
          if((ADXLineLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(DIMinusADXCrossingAlert)
               Alert("-D crossed ADX at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(DIMinusADXCrossingEmail)
               SendNotification("ADX Line Cross signal -D>ADX","-D crossed ADX at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXLineLastAlert=Time[0];
            }
      }         
      if(ADXLevel>b4main && ADXLevel<nowmain)
      {
          if((ADXLevelLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(ADXLevelCrossingAlert)
               Alert("ADX crossed ADXLevel at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(ADXLevelCrossingEmail)
               SendNotification("ADX Line Cross signal ADX>ADXLevel","ADX crossed ADXLevel at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXLevelLastAlert=Time[0];
            }
      }
      
      if(ADXLevel<b4main && ADXLevel>nowmain)
      {
          if((ADXLevelLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(ADXLevelCrossingAlert)
               Alert("ADXLevel crossed ADX at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(ADXLevelCrossingEmail)
               SendNotification("ADX Line Cross signal ADXLevel>ADX","ADXLevel crossed ADX at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXLevelLastAlert=Time[0];
            }
      }
      /////////////////////////////
      if((b4main-b4b4main)>=PointsOfSnap && (b4main-nowmain)>=PointsOfSnap)
      {
          if((ADXSnapMainLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(ADXSnapMainAlert)
               Alert("ADX Line Main has snapped at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(ADXSnapMainEmail)
               SendNotification("ADX Line Main has snapped","ADX Line Main has snapped at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXSnapMainLastAlert=Time[0];
            }
      }                 
      
      if((b4plusdi-b4b4plusdi)>=PointsOfSnap && (b4plusdi-nowplusdi)>=PointsOfSnap)
      {
          if((ADXSnapPlusLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(ADXSnapPlusAlert)
               Alert("ADX Line PlusDI has snapped at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(ADXSnapPlusEmail)
               SendNotification("ADX Line PlusDI has snapped","ADX Line PlusDI has snapped at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXSnapPlusLastAlert=Time[0];
            }
      }     
      
      if((b4minusdi-b4b4minusdi)>=PointsOfSnap && (b4minusdi-nowminusdi)>=PointsOfSnap)
      {
          if((ADXSnapMinusLastAlert<Time[shift])&&(shift==0)&&(limit<=1))
            {
             if(ADXSnapPlusAlert)
               Alert("ADX Line MinusDI has snapped at Ask=",Ask,", Bid=",Bid,", Time=",TimeToStr(TimeCurrent())," Symbol=",Symbol()," Period=",Period());
            if(ADXSnapMinusEmail)
               SendNotification("ADX Line MinusDI has snapped","ADX Line MinusDI has snapped at Ask="+DoubleToStr(Ask,Digits)+", Bid="+DoubleToStr(Bid,Digits)+", Time="+TimeToStr(TimeCurrent())+" Symbol="+Symbol()+" Period="+Period());
             ADXSnapMinusLastAlert=Time[0];
            }
      }
      
   }
   return(0);
  }
//+------------------------------------------------------------------+
 
Peter Fenderson:

Hello, can anyone fix this code?  I'm trying to change it from send email alert to send a push notification.  Thanks!

And what is the problem?

Check your terminal: Ctrl+O => (tab) Notifications.

Have you got and do you know your MQ-ID? Have you read: https://www.mql5.com/en/articles/476.

Have you checked you logs? What do they tell you?

MetaQuotes ID in MetaTrader Mobile Terminal
MetaQuotes ID in MetaTrader Mobile Terminal
  • www.mql5.com
Android and iOS powered devices offer us many features we do not even know about. One of these features is push notifications allowing us to receive personal messages, regardless of our phone number or mobile network operator. MetaTrader mobile terminal already can receive such messages right from your trading robot. You should only know MetaQuotes ID of your device. More than 9 000 000 mobile terminals have already received it.
 

I keep getting this error when compiling:


'SendNotification' - wrong parameters count 

 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time, post in the correct place. The moderators will likely move this thread there soon.


  2. Peter Fenderson #: 'SendNotification' - wrong parameters count 

    Perhaps you should read the manual. SendNotification - Common Functions - MQL4 Reference
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

    Your code
    Documentation
    SendNotification(
    "ADX Line PlusDI has snapped",
    "ADX Line PlusDI has snapped at Ask=…
    );
    bool  SendNotification(
       string  text   // Text of the notification
               
       );
 

Check your terminal: Ctrl+O => (tab) Notifications.   Checked, everything okay.

Have you got and do you know your MQ-ID? Have you read: https://www.mql5.com/en/articles/476Absolutely, been using the same ID for years, receiving all other alerts no problem.

Have you checked you logs? What do they tell you?  Nothing to see in logs, problem is with the code.

MetaQuotes ID in MetaTrader Mobile Terminal
MetaQuotes ID in MetaTrader Mobile Terminal
  • www.mql5.com
Android and iOS powered devices offer us many features we do not even know about. One of these features is push notifications allowing us to receive personal messages, regardless of our phone number or mobile network operator. MetaTrader mobile terminal already can receive such messages right from your trading robot. You should only know MetaQuotes ID of your device. More than 9 000 000 mobile terminals have already received it.
 
William Roeder #:

Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
          General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time, post in the correct place. The moderators will likely move this thread there soon.

Sorry! New to the forum.
Reason: