JBrainTrend1Stop_Alert - MetaTrader 5 Script - MT4/MT5 Resources


JBrainTrend1Stop trend indicator features alerts, emails and push notifications.
In order to implement alerts, email messages and push notifications, the following changes were made to the indicator code:
Input unit number = 1 ; //The number of bars of the signal Input boolean sound on = true ; //enable alert Input unit alarm number = 2 ; //Alarm number input boolean email-on = false ; //enable mailing signal input boolean pressed = false ; //enable signaling to mobile devices
//|Buy signal function |
//+------------------------------------------------------------------+
Blank buy signal( string signal sir name, // indicator name text for emails and push messages
Double buy arrow(&B)[], // indicator buffer with uptrend signals
Double sales arrow(&S)[], // indicator buffer with downtrend signals
Constant integer rate_total, // current number of bars
Constant integer BEFORE_CALCULATION, // number of bars of the previous price change
const double & close [], // closing price
const int & spread[]) // spread
{
//---
static unit counter = 0 ;
if (Rates_total!=Prev_calculated) counter = 0 ;
boolean buysignal = false ;
booleanSeriesTest = array getSeries (BuyArrow);
integer index, index 1;
if (series test)
{
Index = integer (number of items);
index1=index+ 1 ;
}
Others
{
Index=Rates_total- integer (number of items) -1 ;
index1=index- 1 ;
}
if (SellArrow[index1] && SellArrow[index1]!= null_VALUE && BuyArrow[index] && BuyArrow[index]!= null_VALUE ) buy signal= true ;
if (BuySignal && counter<=NumberofAlerts)
{
counter++;
MqlDateTimeTM ;
BuildTime ( timecurrent (),tm);
string literal = string time ( timecurrent (), TIME_DATE ) + "" + string (tm.hour) + ":" + string (tm.minute);
SeriesTest = arrayGetSeries ( close );
if (series test) index = integer (number of items);
Other indexes=Rates_total- integer (number of items) -1 ;
double question = close [index];
double bid = close [index];
SeriesTest = arrayGetSeries (spread);
if (series test) index = integer (number of items);
Other indexes=Rates_total- integer (number of items) -1 ;
bid += _views *spread[index];
Thin string question = double to string ( question , _number );
stringbid = double to string ( bid , _number );
String sPeriod=GetStringTimeframe( ChartPeriod ());
if (sound on) alert ( "buy signal\n ask=" , ask , "\n bid=" , bid , "\n current time=" , text, "\n symbol=" , symbol (), "period=" ,s period);
if (email) send mail (signal sir name + ": buy signal alert" , "buy signal at inquiry =" + ask + ", bid =" + bid + ", date = " + text + " symbol = " + symbol () + " period = " + s period);
if (push) send notification (signal sir name + ": Buy signal at Ask=" + ask + ", bid = " + bid + ", date = " + text + " symbol = " + symbol () + " period = " + s period);
}
//---
}
//+------------------------------------------------------------------+
//|Sell signal function |
//+------------------------------------------------------------------+
Blank sell signal( string signal sir name, // indicator name text for emails and push messages
Double sales arrow(&S)[], // indicator buffer with downtrend signals
Double buy arrow(&B)[], // indicator buffer with uptrend signals
Constant integer rate_total, // current number of bars
Constant integer BEFORE_CALCULATION, // number of bars of the previous price change
const double & close [], // closing price
const int & spread[]) // spread
{
//---
static unit counter = 0 ;
if (Rates_total!=Prev_calculated) counter = 0 ;
boolean sell_signal = false ;
booleanSeriesTest = array getSeries (SellArrow);
integer index, index 1;
if (series test)
{
Index = integer (number of items);
index1=index+ 1 ;
}
Others
{
Index=Rates_total- integer (number of items) -1 ;
index1=index- 1 ;
}
if (BuyArrow[index1] && BuyArrow[index1]!= null_VALUE && SellArrow[index] && SellArrow[index]!= null_VALUE ) sell signal= true ;
if (SellSignal && counter<=NumberofAlerts)
{
counter++;
MqlDateTimeTM ;
BuildTime ( timecurrent (),tm);
string literal = string time ( timecurrent (), TIME_DATE ) + "" + string (tm.hour) + ":" + string (tm.minute);
SeriesTest = arrayGetSeries ( close );
if (series test) index = integer (number of items);
Other indexes=Rates_total- integer (number of items) -1 ;
double question = close [index];
double bid = close [index];
SeriesTest = arrayGetSeries (spread);
if (series test) index = integer (number of items);
Other indexes=Rates_total- integer (number of items) -1 ;
bid += _views *spread[index];
Thin string question = double to string ( question , _number );
stringbid = double to string ( bid , _number );
String sPeriod=GetStringTimeframe( ChartPeriod ());
if (sound on) alert ( "sell signal\n ask=" , ask , "\n bid=" , bid , "\n current time=" , text, "\n symbol=" , symbol (), "period=" ,s period);
if (email) send mail (signal sir name + ": sell signal alert" , "sell signal in ask=" + ask + ", bid = " + bid + ", date = " + text + " symbol = " + symbol () + " period = " + s period);
if (push) send notification (signal sir name + ": sell signal at Ask=" + ask + ", bid =" + bid + ", date = " + text + " symbol = " + symbol () + " period = " + s period);
}
//---
}
//+------------------------------------------------------------------+
//| Get the time range in string form |
//+------------------------------------------------------------------+
String gets string time range ( ENUM_TIMEFRAMES approximate time)
{
//----
Return ( string substring ( enumeration to string (approximate time), 7 ,- 1 ));
//----
}
Buy signal( “JBrainTrend1Stop_Alert” ,BuyStopBuffer,SellStopBuffer,rates_total,prev_calculated,close,spread);
Sell signal( “JBrainTrend1Stop_Alert” ,SellStopBuffer,BuyStopBuffer,rates_total,prev_calculated,close,spread);
//---
Where BuyStopBuffer and SellStopBuffer are the names of indicator buffers used to store up and down trend signals (stop lines for long and short positions). If there is no appropriate trend, zero value or EMPTY_VALUE should be present in the indicator buffer.
It is assumed that the only calls to the BuySignal() and SellSignal() functions will be used in the OnCalculate() block of the indicator code.
Place the JMA.mq5 indicator compiled file into MQL5\Indicators.

Figure 1. JBrainTrend1Stop_Alert indicator on the chart

Figure 2. JBrainTrend1Stop_Alert indicator. Generate alert
Attachment download
📎 jma.mq5 (47.27 KB)
📎 jbraintrend1stop_alert.mq5 (36.04 KB)
Source: MQL5 #16895
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •