Download MetaTrader 5

HOW CAN I GET EMAIL ALRETS WHEN MY INDICATOR ALERTS ME ON MY CHART

To add comments, please log in or register
karlie4nia
124
karlie4nia  
Please anyone has any idea or know hoe i can get an email alert on my email whenever my indicator gives an alert on my chart. I have already set up my email with metatrader 4 and i have successfully sent test message applying all the SMTP settings.Thanks.
Trinh Dat
37968
Trinh Dat  

Hi

need add SendMail to your indicator

SendMail - MQL4 Documentation
  • docs.mql4.com
SendMail - MQL4 Documentation
Mehrdad Shiri
4535
Mehrdad Shiri  
karlie4nia:
Please anyone has any idea or know hoe i can get an email alert on my email whenever my indicator gives an alert on my chart. I have already set up my email with metatrader 4 and i have successfully sent test message applying all the SMTP settings.Thanks.

Forum on trading, automated trading systems and testing trading strategies

share utility code

TIMisthebest, 2014.03.18 08:43

hi;

below code can use for " send email & send massage to mobile & send sound and alarm " .i write below and use it in all my indicator.

uint counterBUY=0;
uint counterSELL=0;
double Ask,Bid;
string text,sAsk,sBid,sPeriod;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
input string s99="-----------------------------------------------";      // ----------- ALARM Settings -----------------
input uint Numberof_Alerts_Maximum_Iterations=2;
input bool On_Push = true;                        //allow to send push-messages
input bool On_Email = true;                       //allow to send e-mail messages
input bool On_Alert= true;                        //allow to put alert
input bool On_Play_Sound = true;                  //allow to put sound signal
input string NameFileSound="request.wav";          //name of the file with sound in "...\MetaTrader 5\Sounds"
input string  CommentSirName="your indicator name:";  //the first part of the allert comment
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+------------------------------------------------------------------+
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     &TickVolume[],
                const long     &Volume[],
                const int      &Spread[])
{

//----------------------------------------------------------------------//
   MqlDateTime tm;
   TimeToStruct(TimeCurrent(),tm);
   text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
   Ask=Close[0];
   Bid=Close[0]+Spread[0];
   sAsk=DoubleToString(Ask,_Digits);
   sBid=DoubleToString(Bid,_Digits);
   sPeriod=EnumToString(ChartPeriod());
   if(rates_total!=prev_calculated) {counterBUY=0;counterSELL=0;}
//----------------------------------------------------------------------//      

//----------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------- PlaySound Alert SendNotification SendMail 
//+++
     {
      if(counterBUY<Numberof_Alerts_Maximum_Iterations)
        {
         if(Indicator_Signal[0]==1&&Indicator_Signal[1]!=1) {BUY_ALARM();counterBUY++;}
        }
      if(counterSELL<Numberof_Alerts_Maximum_Iterations)
        {
         if(Indicator_Signal[0]==-1&&Indicator_Signal[1]!=-1) {SELL_ALARM();counterSELL++;}
        }
     }
//----------------------------------------------------------------------------------------------------------//
//--- done
   return(rates_total);
}
//+------------------------------------------------------------------+
//----------------------------------------------------------------------------------------------------------//
//********************************************************************************************************************
void BUY_ALARM()
  {
   if(On_Alert) Alert("BUY # ",Symbol(),"\n Period=",sPeriod,"\n Ask=",sAsk,"\n Bid=",sBid,"\n currtime=",text);
   if(On_Play_Sound) PlaySound("matrixrevolution.wav");
   if(On_Email) SendMail("BUY #",Symbol()+" Period="+sPeriod+", Ask="+sAsk+", Bid="+sBid+", currtime="+text);
   if(On_Push) SendNotification("BUY #"+Symbol()+" Period="+sPeriod+", Ask="+sAsk+", Bid="+sBid+", currtime="+text);
  }
//+------------------------------------------------------------------+
void SELL_ALARM()
  {
   if(On_Alert) Alert("SELL # ",Symbol(),"\n Period=",sPeriod,"\n Ask=",sAsk,"\n Bid=",sBid,"\n currtime=",text);
   if(On_Play_Sound) PlaySound("matrixrevolution.wav");
   if(On_Email) SendMail("SELL #",Symbol()+" Period="+sPeriod+", Ask="+sAsk+", Bid="+sBid+", currtime="+text);
   if(On_Push) SendNotification("SELL #"+Symbol()+" Period="+sPeriod+", Ask="+sAsk+", Bid="+sBid+", currtime="+text);
  }
//********************************************************************************************************************
//----------------------------------------------------------------------------------------------------------//

example : https://www.mql5.com/en/code/1868

see this maybe help.
To add comments, please log in or register