Wirklicher Autor: Eng. Waddah Attar
Der Waddah_Attar_Trend Indikator. Sendet Alerts, E-Mails und Push-Benachrichtigungen an Smartphone.
Für das Senden von Alerts, E-Mails und Push-Benachrichtigungen wurden im Code des Indikators die folgenden Änderungen vorgenommen:
- Es wurden neue Eingabevariablen den Eingabeparametern hinzugefügt
input uint NumberofBar=1;
input bool SoundON=true;
input uint NumberofAlerts=2;
input bool EMailON=false;
input bool PushON=false;
- Es wurden drei neue Funktionen BuySignal(), SellSignal() und GetStringTimeframe() am Ende des Codes hinzugefügt
void BuySignal(string SignalSirname,
double &ColorArray[],
int ColorIndex,
const int Rates_total,
const int Prev_calculated,
const double &Close[],
const int &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);
}
}
void SellSignal(string SignalSirname,
double &ColorArray[],
int ColorIndex,
const int Rates_total,
Anzahl der Balken auf dem vorherigen Tick
const double &Close[],
const int &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);
}
}
string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)
{
return(StringSubstr(EnumToString(timeframe),7,-1));
}
- Es wurden einige Aufrufe von BuySignal() und SellSignal() in den OnCalculate() Block nach den Berechnungsschleifen hinuzugefügt
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);
Wobei: ColorIndBuffer - Name des Index-Puffers für das Speichern der Farbe der Linie als Index, 0 und 1 - Farbennummern im Index-Puffer.
Es wird angenommen, dass der Aufruf der BuySignal() und SellSignal() Funktionen im OnCalculate() Block nur einmal im Code des Indikators verwendet wird.
Der Indikator verwendet die Klassen der Bibliothek SmoothAlgorithms.mqh (kopieren Sie diese nach <terminal_data_folder>\MQL5\Include). Die Klassen wurden im Artikel "Bildung von Kursreihenmittelwerten für Zwischenberechnungen ohne zusätzliche Puffer" ausführlich beschrieben.

Abb.1. Der Waddah_Attar_Trend_Alert Indikator auf dem Chart

Abb.2. Der Waddah_Attar_Trend_Alert Indikator. Das Senden eines Alerts