Unlocking BykovTrendAlert: Your Go-To Indicator for MT5 Alerts

Mike 2017.01.18 18:49 55 0 0
Attachments

Meet the Creator:

Ramdass - Conversion only

The BykovTrend semaphore signal indicator is a game-changer for traders using MetaTrader 5. It comes equipped with alerts, email notifications, and push notifications to keep you informed on the go.

To enhance the functionality of this indicator, several updates have been made to the code, enabling alerts, email messages, and mobile notifications:

  1. New input parameters have been introduced:
    input uint NumberofBar=1;// Bar number for 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. Added three new functions at the end of the indicator code: 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, // the current number of bars
          const int Prev_calculated,// the number of bars 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;
       if(SeriesTest) index=int(NumberofBar);
       else index=Rates_total-int(NumberofBar)-1;
       if(NormalizeDouble(BuyArrow[index],_Digits) && BuyArrow[index]!=EMPTY_VALUE) 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];
         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,// the current number of bars
          const int Prev_calculated,// the number of bars 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;
       if(SeriesTest) index=int(NumberofBar);
       else index=Rates_total-int(NumberofBar)-1;
       if(NormalizeDouble(SellArrow[index],_Digits) && SellArrow[index]!=EMPTY_VALUE) 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];
         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. In the OnCalculate() block of the indicator, calls to BuySignal() and SellSignal() functions have been added:
    //---     
       BuySignal("BykovTrendAlert", BuyBuffer, rates_total, prev_calculated, close, spread);
       SellSignal("BykovTrendAlert", SellBuffer, rates_total, prev_calculated, close, spread);
    //--- 
    

In this code, BuyBuffer and SellBuffer are the buffers used to store buy and sell signals. Ensure that empty values in these buffers are set as either zeros or EMPTY_VALUE.

For optimal results, each signal function should be called only once in the OnCalculate() block.

This indicator was initially developed in MQL4 and made its debut in the Code Base on September 28, 2007.

Fig1. The BykovTrendAlert indicator on the chart

Fig1. The BykovTrendAlert indicator on the chart


Fig.2. The BykovTrendAlert indicator Generating alerts.

Fig.2. The BykovTrendAlert indicator Generating alerts.

List
Comments 0