Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Indicators

RJTX_Matches_Smoothed_Alert - indicator for MetaTrader 5

Views:
5107
Rating:
(14)
Published:
2018.12.28 13:09
Updated:
2023.03.29 13:48
\MQL5\Include\
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Real author:

Rafael Jimenez Tocino

Indicator RJTX_Matches_Smoothed featuring alerts, emails and push notifications for smartphones.

The following changes have been made to the indicator code in order to implement alerts, email messages and push-notifications:

  1. New input variables are added to the indicator inputs
    input uint NumberofBar=1;                 // Bar number to activate the signal
    input bool SoundON=true;           // Enable alerts
    input uint NumberofAlerts=2;       // Number of alerts
    input bool EMailON=false;          // Enable mailing the signal
    input bool PushON=false;           // Enable sending the signal to mobile devices
    


  2. Three new functions have been added to the end of the indicator: BuySignal(), SellSignal(), and GetStringTimeframe()
    //+------------------------------------------------------------------+
    //| Buy signal function                                              |
    //+------------------------------------------------------------------+
    void BuySignal(string SignalSirname,      // text of the indicator name for email and push messages
                   double &BuyArrow[],        // indicator buffer with buy signals
                   const int Rates_total,     // current number of bars
                   const int Prev_calculated, // number of bar on the previous tick
                   const double &Close[],     // close price
                   const int &Spread[])       // spread
      {
    //---
       static uint counter=0;
       if(Rates_total!=Prev_calculated) counter=0;
    
       bool BuySignal=false;
       bool SeriesTest=ArrayGetAsSeries(BuyArrow);
       int index,index1;
       if(SeriesTest)
        {
         index=int(NumberofBar);
         index1=index+1;
        }
       else
         {
          index=Rates_total-int(NumberofBar)-1;
          index1=index-1;
         }
       if(!BuyArrow[index1] && BuyArrow[index]) BuySignal=true;
       if(BuySignal && counter<=NumberofAlerts)
         {
          counter++;
          MqlDateTime tm;
          TimeToStruct(TimeCurrent(),tm);
          string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
          SeriesTest=ArrayGetAsSeries(Close);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          double Ask=Close[index];
          double Bid=Close[index];
          SeriesTest=ArrayGetAsSeries(Spread);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          Bid+=Spread[index]*_Point;
          string sAsk=DoubleToString(Ask,_Digits);
          string sBid=DoubleToString(Bid,_Digits);
          string sPeriod=GetStringTimeframe(ChartPeriod());
          if(SoundON) Alert("BUY signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": BUY signal alert","BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
         }
    
    //---
      }
    //+------------------------------------------------------------------+
    //| Sell signal function                                             |
    //+------------------------------------------------------------------+
    void SellSignal(string SignalSirname,      // text of the indicator name for email and push messages
                    double &SellArrow[],       // indicator buffer with sell signals
                    const int Rates_total,     // current number of bars
                    const int Prev_calculated, // number of bar on the previous tick
                    const double &Close[],     // close price
                    const int &Spread[])       // spread
      {
    //---
       static uint counter=0;
       if(Rates_total!=Prev_calculated) counter=0;
    
       bool SellSignal=false;
       bool SeriesTest=ArrayGetAsSeries(SellArrow);
       int index,index1;
       if(SeriesTest)
        {
         index=int(NumberofBar);
         index1=index+1;
        }
       else
         {
          index=Rates_total-int(NumberofBar)-1;
          index1=index-1;
         }
       if(!SellArrow[index1] && SellArrow[index]) SellSignal=true;
       if(SellSignal && counter<=NumberofAlerts)
         {
          counter++;
          MqlDateTime tm;
          TimeToStruct(TimeCurrent(),tm);
          string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
          SeriesTest=ArrayGetAsSeries(Close);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          double Ask=Close[index];
          double Bid=Close[index];
          SeriesTest=ArrayGetAsSeries(Spread);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          Bid+=Spread[index]*_Point;
          string sAsk=DoubleToString(Ask,_Digits);
          string sBid=DoubleToString(Bid,_Digits);
          string sPeriod=GetStringTimeframe(ChartPeriod());
          if(SoundON) Alert("SELL signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": SELL signal alert","SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
         }
    //---
      }
    //+------------------------------------------------------------------+
    //|  Getting the timeframe as a string                               |
    //+------------------------------------------------------------------+
    string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)
      {
    //----
       return(StringSubstr(EnumToString(timeframe),7,-1));
    //----
      }
    


  3. A couple of calls to functions BuySignal() and SellSignal() has been added following the indicator calculation cycles in block OnCalculate()
    //---     
       BuySignal("RJTX_Matches_Smoothed_Alert",BuyBuffer,rates_total,prev_calculated,close,spread);
       SellSignal("RJTX_Matches_Smoothed_Alert",SellBuffer,rates_total,prev_calculated,close,spread);
    //---
    


Where BuyBuffer and SellBuffer are the names of the indicator buffers for storing the buy and sell signals. Either zeros or EMPTY_VALUE must be added to indicator buffers as empty values.

Only one call to each of functions BuySignal() and SellSignal() is assumed to be used in the indicator code in block OnCalculate().

The indicator uses the classes of library SmoothAlgorithms.mqh (to be copied to the <terminal_data_directory>\MQL5\Include folder). The use of the classes was thoroughly described in article Averaging Price Series for Intermediate Calculations Without Using Additional Buffers.

This indicator was first implemented in MQL4 and published in the Code Base on December 23, 2015.


Fig.1. Indicator RJTX_Matches_Smoothed_Alert on the chart

Fig.1. RJTX_Matches_Smoothed_Alert indicator on the chart


Fig. 2. Indicator RJTX_Matches_Smoothed_Alert. Alerting

Fig. 2. Indicator RJTX_Matches_Smoothed_Alert. Alerting

Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/22712

RJTX_Matches_Smoothed_Alert_xx RJTX_Matches_Smoothed_Alert_xx

Indicator RJTX_Matches_Smoothed_Alert featuring alerts, emails and push notifications for smartphones. The input variables allow replacing the displayed indicator symbols

VZO VZO

Indicator VZO

HLCrossSigForWPR_HTF HLCrossSigForWPR_HTF

Indicator HLCrossSigForWPR with the option of selecting its timeframe in its input parameters

BestInterval BestInterval

Calculating the best trading interval.