Ticaret robotlarını ücretsiz olarak nasıl indirebileceğinizi izleyin
Bizi Facebook üzerinde bulun!
Fan sayfamıza katılın
Komut dosyasını ilginç mi buldunuz?
Öyleyse bir link gönderin -
başkalarının da faydalanmasını sağlayın
Komut dosyasını beğendiniz mi? MetaTrader 5 terminalinde deneyin
Göstergeler

ColorXdinMA_Alert - MetaTrader 5 için gösterge

Görüntülemeler:
7131
Derecelendirme:
(19)
Yayınlandı:
2017.01.26 09:28
Güncellendi:
2023.03.29 13:47
Bu koda dayalı bir robota veya göstergeye mi ihtiyacınız var? Freelance üzerinden sipariş edin Freelance'e git

Real Author: dimeon

The ColorXdinMA trend moving average, 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. Enumeration for the options of indicator signal generation is declared at the global scope before the input variables are declared.
    //+----------------------------------------------------+
    //| Enumeration for signal generation options   |
    //+----------------------------------------------------+
    enum ENUM_SIGNAL_MODE
      {
       MODE_SIGNAL,  //Breakout signals
       MODE_TREND    //Breakout and trend signals
      };
  2. Introduced new input parameters
    //---- Input variables for alerts
    input ENUM_SIGNAL_MODE SignMode=MODE_SIGNAL; //Signal generation mode
    input uint NumberofBar=1;                    //Number of the bar to generate a 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
  3. 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(SignMode==MODE_SIGNAL)
         {
          if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) BuySignal=true;
         }
       else
         {
          if(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+=_Point*Spread[index];
          string sAsk=DoubleToString(Ask,_Digits);
          string sBid=DoubleToString(Bid,_Digits);
          string sPeriod=GetStringTimeframe(ChartPeriod());
          if(SignMode==MODE_SIGNAL || (SignMode==MODE_TREND && ColorArray[index1]!=ColorIndex))
            {
             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);
            }
          else
            {
             if(SoundON) Alert("Up Trend signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
             if(EMailON) SendMail(SignalSirname+": Up Trend signal alert","BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
             if(PushON) SendNotification(SignalSirname+": Up Trend 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(SignMode==MODE_SIGNAL)
         {
          if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) SellSignal=true;
         }
       else
         {
          if(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+=_Point*Spread[index];
          string sAsk=DoubleToString(Ask,_Digits);
          string sBid=DoubleToString(Bid,_Digits);
          string sPeriod=GetStringTimeframe(ChartPeriod());
          if(SignMode==MODE_SIGNAL || (SignMode==MODE_TREND && ColorArray[index1]!=ColorIndex))
            {
             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);
            }
          else
            {
             if(SoundON) Alert("Down trend signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
             if(EMailON) SendMail(SignalSirname+": Down trend signal alert","SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
             if(PushON) SendNotification(SignalSirname+": Down trend 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));
    //----
      }
  4. Added a couple of calls to BuySignal() and SellSignal() functions after the indicator calculation cycles in the OnCalculate() block
    //---    
       BuySignal("ColorXdinMA_Alert",ColorXdinMA,1,rates_total,prev_calculated,close,spread);
       SellSignal("ColorXdinMA_Alert",ColorXdinMA,2,rates_total,prev_calculated,close,spread);
    //--- 

Where ColorXdinMA is the name of the color index buffer for storing indicator colors. Values 1 and 2 are the numbers of colors in this buffer, at which the moving average is ascending or descending, respectively. 

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 ColorXdinMA_Alert indicator on the chart

Fig1. The ColorXdinMA_Alert indicator on the chart

Fig.2. The ColorXdinMA_Alert indicator. Generating alert for breakout signal

Fig.2. The ColorXdinMA_Alert indicator. Generating alert for breakout signal

Fig.3. The ColorXdinMA_Alert indicator. Generating alert for trend signal

Fig.3. The ColorXdinMA_Alert indicator. Generating alert for trend signal

MetaQuotes Ltd tarafından Rusçadan çevrilmiştir.
Orijinal kod: https://www.mql5.com/ru/code/17111

Fractal_WeightOscillator Fractal_WeightOscillator

Oscillator, representing the weighted smoothed sum of four indicators: Fractal_RSI, Fractal_MFI, Fractal_WPR and Fractal_DeMarker.

Fractal_MFI Fractal_MFI

Fractal Money Flow Index.

FT BillWillams Trader FT BillWillams Trader

The Expert Advisor based on the iAlligator (Alligator), iMA (Moving Average) indicators.

ZeroLagEA-AIP v0.0.4 ZeroLagEA-AIP v0.0.4

Trading based on the ZeroLag MACD custom indicator.