거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
7004
평가:
(15)
게시됨:
2017.01.19 16:59
업데이트됨:
2023.03.29 13:47
\MQL5\Include\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

Real Author: Eng. Waddah Attar

Waddah_Attar_Trend indicator features alerts, emails and push notifications.

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
    //---- Inputs 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 for generating a signal
    const int Rates_total, // current number of bars
    const int Prev_calculated, // 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+=_Point*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 for generating a signal
    const int Rates_total, // current number of bars
    const int Prev_calculated, // 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+=_Point*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 a 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("Waddah_Attar_Trend_Alert",ColorIndBuffer,0,rates_total,prev_calculated,close,spread);
    SellSignal("Waddah_Attar_Trend_Alert",ColorIndBuffer,1,rates_total,prev_calculated,close,spread);
    //---

where ColorIndBuffer is a name of a color index buffer for storing a line color as an index, while 0 and 1 are the numbers of colors in the color index buffer.

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 SmoothAlgorithms.mqh library classes (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".

Fig.1. Waddah_Attar_Trend_Alert indicator on the chart

Fig.1. Waddah_Attar_Trend_Alert indicator on the chart

Fig.2. Waddah_Attar_Trend_Alert indicator. Generating alerts

Fig.2. Waddah_Attar_Trend_Alert indicator. Generating alerts

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/16832

Exp_ReOpenPositions Exp_ReOpenPositions

The Expert Advisor increases the volume of an open position if profit in points from the last trade increases a threshold fixed in the EA inputs.

Exp_TralingStop Exp_TralingStop

The Expert Advisor moves a stop loss to a predefined fixed distance from the current price.

EMA CROSS EMA CROSS

Crossing of the two iMAs.

Fibo iSAR Fibo iSAR

The Expert Advisor uses Fibo levels and iSAR indicator - Parabolic Stop and Reverse system. Trading is performed using BuyLimit and SellLimit orders.