#property link "https://www.earnforex.com/metatrader-indicators/bollinger-bands-breakout-alert/"
#property version "1.02"
#property strict
#property copyright "EarnForex.com - 2019-2020"
#property description "The classic Bollinger Bands with more features"
#property description " "
#property description "WARNING : You use this software at your own risk."
#property description "The creator of these plugins cannot be held responsible for damage or loss."
#property description " "
#property description "Find More on EarnForex.com"
//#property icon "\\Files\\EF-Icon-64x64px.ico"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen
//#include <MQLTA ErrorHandling.mqh>
//#include <MQLTA Utils.mqh>
enum ENUM_TRADE_SIGNAL{
SIGNAL_BUY=1, //BUY
SIGNAL_SELL=-1, //SELL
SIGNAL_NEUTRAL=0 //NEUTRAL
};
enum ENUM_CANDLE_TO_CHECK{
CURRENT_CANDLE=0, //CURRENT CANDLE
CLOSED_CANDLE=1 //PREVIOUS CANDLE
};
enum ENUM_ALERT_SIGNAL{
ON_BREAK_OUT=0, //ON BREAK OUT OF BANDS
ON_BOUNCE_IN=1, //ON RE-ENTER IN BANDS
};
enum ENUM_ARROW_SIZE{
ARROW_SIZE_AUTO=0, //AUTOMATIC SIZE
ARROW_SIZE_VERYSMALL=1, //VERY SMALL
ARROW_SIZE_SMALL=2, //SMALL
ARROW_SIZE_MEDIUM=3, //MEDIUM
ARROW_SIZE_BIG=4, //BIG
ARROW_SIZE_VERYBIG=5, //VERY BIG
};
input string Comment1="========================"; //MQLTA Bollinger Bands With Alert
input string IndicatorName="MQLTA-BBWA"; //Indicator Short Name
input string Comment2="========================"; //Indicator Parameters
input int InpBandsPeriod=20; // Bands Period
input int InpBandsShift=0; // Bands Shift
input double InpBandsDeviations=2.0; // Bands Deviations
input ENUM_APPLIED_PRICE InpBandsAppliedPrice=PRICE_CLOSE; //Bands Applied Price
input ENUM_ALERT_SIGNAL AlertSignal=ON_BREAK_OUT; //Alert Signal When
input ENUM_CANDLE_TO_CHECK CandleToCheck=CURRENT_CANDLE; //Candle To Use For Analysis
input int BarsToScan=500; //Number Of Candles To Analyse
input string Comment_3="===================="; //Notification Options
extern bool EnableNotify=false; //Enable Notifications Feature
extern bool SendAlert=true; //Send Alert Notification
extern bool SendApp=true; //Send Notification to Mobile
extern bool SendEmail=true; //Send Notification via Email
input int WaitTimeNotify=5; //Wait time between notifications (Minutes)
input string Comment_4="===================="; //Drawing Options
input bool EnableDrawArrows=true; //Draw Signal Arrows
input int ArrowBuy=241; //Buy Arrow Code
input int ArrowSell=242; //Sell Arrow Code
input int ArrowSize=3; //Arrow Size (1-5)
double BufferUpperBand[];
double BufferLowerBand[];
double BufferSMA[];
datetime LastNotificationTime;
int Shift=0;
int OnInit(void){
IndicatorSetString(INDICATOR_SHORTNAME,IndicatorName);
OnInitInitialization();
if(!OnInitPreChecksPass()){
return(INIT_FAILED);
}
InitialiseBuffers();
return(INIT_SUCCEEDED);
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[]){
bool IsNewCandle=CheckIfNewCandle();
int i,pos,upTo;
pos=0;
if(prev_calculated==0 || IsNewCandle)
upTo=BarsToScan-1;
else
upTo=0;
for(i=pos; i<=upTo && !IsStopped(); i++){
BufferSMA[i]=iBands(Symbol(),PERIOD_CURRENT,InpBandsPeriod,InpBandsDeviations,InpBandsShift,InpBandsAppliedPrice,MODE_MAIN,i);
BufferUpperBand[i]=iBands(Symbol(),PERIOD_CURRENT,InpBandsPeriod,InpBandsDeviations,InpBandsShift,InpBandsAppliedPrice,MODE_UPPER,i);
BufferLowerBand[i]=iBands(Symbol(),PERIOD_CURRENT,InpBandsPeriod,InpBandsDeviations,InpBandsShift,InpBandsAppliedPrice,MODE_LOWER,i);
}
if(IsNewCandle || prev_calculated==0){
if(EnableDrawArrows) DrawArrows();
}
if(EnableDrawArrows)
DrawArrow(0);
if(EnableNotify)
NotifyHit();
return(rates_total);
}
void OnDeinit(const int reason){
CleanChart();
}
void OnInitInitialization(){
LastNotificationTime=TimeCurrent();
Shift=CandleToCheck;
}
bool OnInitPreChecksPass(){
if(InpBandsPeriod<=0){
Print("Wrong input parameter Bands Period=",InpBandsPeriod);
return false;
}
if(Bars(Symbol(),PERIOD_CURRENT)<InpBandsPeriod+InpBandsShift){
Print("Not Enough Historical Candles");
return false;
}
return true;
}
void CleanChart(){
int Window=0;
for(int i=ObjectsTotal(ChartID(),Window,-1)-1;i>=0;i--){
if(StringFind(ObjectName(i),IndicatorName,0)>=0){
ObjectDelete(ObjectName(i));
}
}
}
Tony-Montana