Der JBrainTrend1Stop Trendindikator. 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 &BuyArrow[],
double &SellArrow[],
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(BuyArrow);
int index,index1;
if(SeriesTest)
{
index=int(NumberofBar);
index1=index+1;
}
else
{
index=Rates_total-int(NumberofBar)-1;
index1=index-1;
}
if(SellArrow[index1] && SellArrow[index1]!=EMPTY_VALUE && BuyArrow[index] && 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+=_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 &SellArrow[],
double &BuyArrow[],
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 SellSignal=false;
bool SeriesTest=ArrayGetAsSeries(SellArrow);
int index,index1;
if(SeriesTest)
{
index=int(NumberofBar);
index1=index+1;
}
else
{
index=Rates_total-int(NumberofBar)-1;
index1=index-1;
}
if(BuyArrow[index1] && BuyArrow[index1]!=EMPTY_VALUE && SellArrow[index] && 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+=_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("JBrainTrend1Stop_Alert",BuyStopBuffer,SellStopBuffer,rates_total,prev_calculated,close,spread);
SellSignal("JBrainTrend1Stop_Alert",SellStopBuffer,BuyStopBuffer,rates_total,prev_calculated,close,spread);
wobei BuyStopBuffer und SellStopBuffer - Namen der Puffer des Indikators für das Speichern von Signalen der Ab- und Aufwärtssignalen sind (Stop Ebenen für Long- und Short-Positionen). Als leere Werte müssen in den Puffern entweder Nulls oder EMPTY_VALUE stehen.
Es wird angenommen, dass der Aufruf der BuySignal() und SellSignal() Funktionen im OnCalculate() Block nur einmal im Code des Indikators verwendet wird.
Der Indikator benötigt die kompilierte Datei JMA.mq5. Kopieren Sie sie in den Ordner MQL5\Indicators.

Abb.1. Der JBrainTrend1Stop_Alert Indikator auf dem Chart

Abb.2. Der JBrainTrend1Stop_Alert Indikator auf dem Chart. Das Senden eines Alerts