Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Indicators

JBrainTrend1Stop_Alert - indicator for MetaTrader 5

Views:
5040
Rating:
(16)
Published:
2017.01.19 17:09
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

JBrainTrend1Stop 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
    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 &BuyArrow[],        // indicator buffer with signals for an upward trend
                   double &SellArrow[],       // indicator buffer with signals for a downward trend
                   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(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);
         }

    //---
      }
    //+------------------------------------------------------------------+
    //| Sell signal function                                             |
    //+------------------------------------------------------------------+
    void SellSignal(string SignalSirname,      // text of the indicator name for email and push messages
                    double &SellArrow[],       // indicator buffer with signals for a downward trend
                    double &BuyArrow[],        // indicator buffer with signals for an upward trend
                    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(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);
         }
    //---
      }
    //+------------------------------------------------------------------+
    //|  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("JBrainTrend1Stop_Alert",BuyStopBuffer,SellStopBuffer,rates_total,prev_calculated,close,spread);
       SellSignal("JBrainTrend1Stop_Alert",SellStopBuffer,BuyStopBuffer,rates_total,prev_calculated,close,spread);
    //---  

where BuyStopBuffer and SellStopBuffer are the names of the indicator buffers for storing upward and downward trend signals (stop lines for longs and shorts). Zero value or EMPTY_VALUE should be present in the indicator buffers if there is no appropriate trend.

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.

Place JMA.mq5 indicator compiled file to MQL5\Indicators.


Fig.1. JBrainTrend1Stop_Alert indicator on the chart

Fig.1. JBrainTrend1Stop_Alert indicator on the chart

Fig.2. JBrainTrend1Stop_Alert indicator. Generating alerts

Fig.2. JBrainTrend1Stop_Alert indicator. Generating alerts

Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/16895

Exp_JBrainTrend1Stop_ReOpen Exp_JBrainTrend1Stop_ReOpen

The Exp_JBrainTrend1Stop_ReOpen trading system is based on the JBrainTrend1Stop indicator color change with adding to trend-following positions.

DoubleUp с изгибом DoubleUp с изгибом

The Expert Advisor works comparing iCCI and iMACD indicators.

XMA_BBxATR_Cloud_HTF XMA_BBxATR_Cloud_HTF

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

VR---SETKA---3 VR---SETKA---3

VR---SETKA---3 - MetaTrader 5 Expert Advisor. This is a continuation of VR---SETKA . The EA is based on the martingale principle. Grid. Martingale. Use only on hedge accounts.