Price Data Components
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Bull_Bears_alerts_1a
//+------------------------------------------------------------------+
//| Bears.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_level1 0
#property indicator_levelcolor Magenta
//#property indicator_color3 Blue
//---- input parameters
extern int BBPeriod = 13;
extern int mamode = 3;
extern int price = PRICE_CLOSE;
extern double buylevel = 0.00;
extern double selllevel = 0.00;
extern int histowidth = 4;
extern string note13 = "turn on soundAlert = true; turn off = false";
extern bool SoundON = true;
extern string note15 = "send Email Alert = true; turn off = false";
extern bool EmailON = false;
extern string note17 = "turn on Alert = true; turn off = false";
extern bool AlertON = true;
extern string SoundFileName = "alert.wav";
//---- buffers
double BBUP[], BBDOWN[], avg[];
int flagval1 = 0;
int flagval2 = 0;
double val;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(2);
IndicatorDigits(Digits);
//---- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM,0,histowidth);
SetIndexBuffer(0,BBUP);
SetIndexStyle(1,DRAW_HISTOGRAM,0,histowidth);
SetIndexBuffer(1,BBDOWN);
// SetIndexStyle(2,DRAW_LINE);
// SetIndexBuffer(2, avg);
//---- name for DataWindow and indicator subwindow label
short_name="Bull Bears("+BBPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Bears Power |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit,i;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=limit; i>=0; i--)
{
val = High[i] - iMA(NULL,0,BBPeriod,0,mamode,price,i) + Low[i] - iMA(NULL,0,BBPeriod,0,mamode,price,i);
//for(i=limit; i>=0; i--)
// {
// avg[i] = iMAOnArray(NULL,0,BBPeriod,0,mamode,i);
if (val <= selllevel){
BBDOWN[i] = val;
BBUP[i] = 0;
if (i == 1 && flagval1==0)
{
flagval1=1;
flagval2=0;
if (AlertON) Alert("Bull Bear Sell signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("Bull Bear Sell alert","Sell signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
if (SoundON) PlaySound(SoundFileName);
}
}
else if (val > buylevel)
{
BBDOWN[i] = 0;
BBUP[i] = val;
if (i == 1 && flagval2==0)
{
flagval2=1;
flagval1=0;
if (AlertON) Alert("Bull Bear Buy signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("Bull Bear Buy signal alert","Buy signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
if (SoundON) PlaySound(SoundFileName);
}
}
}
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
---