Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
BB_RSI_v2_AlertEmail
//+------------------------------------------------------------------+
//| SMARSI.mq4 |
//| Typical RSI revised By TrendLaboratory |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//| E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
// Added E-mail Alert by Trader101@optonline.net
#property copyright "Copyright © 2005, TrendLaboratory Ltd."
#property link "http://finance.groups.yahoo.com/group/TrendLaboratory"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 30
#property indicator_level2 50
#property indicator_level3 70
#property indicator_levelcolor DarkSlateGray
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 Yellow
#property indicator_color3 Yellow
#property indicator_color4 Yellow
//---- input parameters
extern int RSIPeriod=14;
extern int BBPeriod=20;
extern int Price=0;
extern int Deviation=2;
extern bool EmailAlert = true; //Added for E-mail Alert purpose
extern bool BoxAlert = true;
//---- buffers
double RSIBuffer[];
double BBBuffer[];
double UpBuffer[];
double DnBuffer[];
double PosBuffer[];
double NegBuffer[];
datetime TimeStamp; //Added for E-mail Alert purpose
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(6);
SetIndexBuffer(4,PosBuffer);
SetIndexBuffer(5,NegBuffer);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,RSIBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,BBBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,UpBuffer);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,DnBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="BBRSI("+RSIPeriod+","+BBPeriod+","+Price+","+Deviation+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"BB mid");
SetIndexLabel(2,"BB up");
SetIndexLabel(3,"BB down");
//----
SetIndexDrawBegin(0,RSIPeriod+BBPeriod);
SetIndexDrawBegin(1,RSIPeriod+BBPeriod);
SetIndexDrawBegin(2,RSIPeriod+BBPeriod);
SetIndexDrawBegin(3,RSIPeriod+BBPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| BB and Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double rel,negative,positive;
//----
if(Bars<=RSIPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=RSIPeriod;i++) RSIBuffer[Bars-i]=0.0;
//----
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
int MAPeriod=1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
for (int k=RSIPeriod-1;k>=0;k--)
{
rel=iMA(NULL,0,MAPeriod,0,MODE_SMA,Price,i+k)-iMA(NULL,0,MAPeriod,0,MODE_SMA,Price,i+k+1);
if(rel>0) sump+=rel;
else sumn-=rel;
}
positive=sump/RSIPeriod;
negative=sumn/RSIPeriod;
PosBuffer[i]=positive;
NegBuffer[i]=negative;
if(negative==0.0) RSIBuffer[i]=0.0;
else RSIBuffer[i]=100.0-100.0/(1+positive/negative);
i--;
}
int total=0;
for (i=Bars-RSIPeriod-BBPeriod-1;i>=0;i--)
{
UpBuffer[i]=iBandsOnArray(RSIBuffer,total,BBPeriod,2,0,MODE_UPPER,i);
DnBuffer[i]=iBandsOnArray(RSIBuffer,total,BBPeriod,2,0,MODE_LOWER,i);
BBBuffer[i]=0.5*(UpBuffer[i]+DnBuffer[i]);
}
//----
//--------------Added for E-mail Alert----------------------
double Rsi1 = RSIBuffer[1];
double BBUp1 = UpBuffer[1];
double BBDn1 = DnBuffer[1];
string alertmessage = "BBRSI Alert " +Symbol()+" chart M"+Period()+" signal: ";
if (Rsi1 > BBUp1 && TimeStamp != Time[0]&& Volume[0]>1)
{
alertmessage = (alertmessage +" OverBought");
if (EmailAlert) SendMail (alertmessage,"");
if (BoxAlert) Alert (alertmessage);
TimeStamp = Time[0];
}
if (Rsi1 < BBDn1 && TimeStamp != Time[0]&& Volume[0]>1)
{
alertmessage = alertmessage+" OverSold";
if (EmailAlert) SendMail (alertmessage,"");
if (BoxAlert) Alert (alertmessage);
TimeStamp = Time[0];
}
//--------------Added for E-mail Alert----------------------
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---