Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Facebook !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Indicateurs

ColorJFatl_Digit_Alert - indicateur pour MetaTrader 5

Vues:
3832
Note:
(13)
Publié:
2017.01.18 09:32
Mise à jour:
2023.03.29 13:47
\MQL5\Include\
Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

The ColorJFatl_Digit indicator, which features alerts, sending emails and push-notifications to mobile devices.

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

  1. Introduced new input parameters
    //---- Input variables for alerts 
    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 to 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 &ColorArray[],// color index buffer
                   int ColorIndex,// color index in the color index buffer to generate a signal
                   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(ColorArray);
       int index,index1;
       if(SeriesTest)
         {
          index=int(NumberofBar);
          index1=index+1;
         }
       else
         {
          index=Rates_total-int(NumberofBar)-1;
          index1=index-1;
         }
       if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) 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 &ColorArray[],       // color index buffer
                    int ColorIndex,             // color index in the color index buffer to generate a signal
                    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(ColorArray);
       int index,index1;
       if(SeriesTest)
         {
          index=int(NumberofBar);
          index1=index+1;
         }
       else
         {
          index=Rates_total-int(NumberofBar)-1;
          index1=index-1;
         }
       if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) 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. Added a couple of calls to BuySignal() and SellSignal() functions after the indicator calculation cycles in the OnCalculate() block
    //---     
       BuySignal("ColorJFatl_Digit_Alert",ColorExtLineBuffer,2,rates_total,prev_calculated,close,spread);
       SellSignal("ColorJFatl_Digit_Alert",ColorExtLineBuffer,0,rates_total,prev_calculated,close,spread);
    //--- 
    

Where ColorExtLineBuffer is the name of the color index buffer for storing line color in the form of an index.

It is assumed that the only one call to the BuySignal() and SellSignal() functions will be used in the OnCalculate() block of the indicator code.

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

Fig1. The ColorJFatl_Digit_Alert indicator on the chart

Fig1. The ColorJFatl_Digit_Alert indicator on the chart

Fig.2. The ColorJFatl_Digit_Alert indicator Generating alerts.

Fig.2. The ColorJFatl_Digit_Alert indicator Generating alerts.

Traduit du russe par MetaQuotes Ltd.
Code original : https://www.mql5.com/ru/code/16407

BalanceOfPower_Histogram_Alert BalanceOfPower_Histogram_Alert

The Balance of Power (BOP) indicator as a color histogram of strength and direction of the current trend, which features alerts, sending emails and push-notifications to mobile devices.

ColorJSatl_Digit_HTF ColorJSatl_Digit_HTF

The ColorJSatl_Digit indicator with the timeframe selection option available in the input parameters.

Exp_ColorJSatl_Digit Exp_ColorJSatl_Digit

The Exp_ColorJSatl_Digit Expert Advisor is based on the ColorJSatl_Digit indicator color change.

Exp_Waddah_Attar_Trend Exp_Waddah_Attar_Trend

The Exp_Waddah_Attar_Trend Expert Advisor is based on the Waddah_Attar_Trend indicator color change.