Author: RoboFx
The Balance of Power (BOP) indicator is a powerful tool for traders, providing a color histogram that illustrates the strength and direction of the current trend. This version includes handy alert features, enabling email notifications and push alerts directly to your mobile device. The histogram colors reflect the overbought and oversold levels, helping you gauge market momentum at a glance.
Here are the key updates made to enhance this indicator with alert functionalities:
- New input parameters have been added to customize your alerts:
- Three new functions have been added: BuySignal(), SellSignal(), and GetStringTimeframe(). Here’s a peek at the BuySignal function:
- Calls to BuySignal() and SellSignal() functions have been added after the indicator calculation cycles in the OnCalculate() block:
//---- Input variables for alerts 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
//+------------------------------------------------------------------+ //| Buy signal function | //+------------------------------------------------------------------+ void BuySignal(string SignalSirname,// Indicator name for alerts double &ColorArray[],// Color index buffer int ColorIndex,// Color index for generating the signal const int Rates_total,// Current number of bars const int Prev_calculated,// Number of bars on the previous tick const double &Close[],// Close prices const int &Spread[])// Spread { //--- static uint counter=0; if(Rates_total!=Prev_calculated) counter=0; bool BuySignal=false; bool SeriesTest=ArrayGetAsSeries(ColorArray); int index,index1; if(SeriesTest) { index=int(NumberofBar); index1=index+1; } else { index=Rates_total-int(NumberofBar)-1; index1=index-1; } if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) 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+=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); } //--- } //+------------------------------------------------------------------+
//--- BuySignal("BalanceOfPower_Histogram_Alert",ColorIndBuffer,0,rates_total,prev_calculated,close,spread); SellSignal("BalanceOfPower_Histogram_Alert",ColorIndBuffer,7,rates_total,prev_calculated,close,spread); //---
Note that ColorIndBuffer represents the color index buffer that stores the candle colors as indices.
This indicator was initially developed in MQL5 and was first published on the Code Base on February 7, 2013.

Balance of Power Histogram Alert on Chart

Balance of Power Histogram Alert Generating Alerts
Related Posts
- Unlock Trading Insights with Volume Profile + Range v6.0 for MetaTrader 5
- Mastering the Open Range Breakout Indicator for MetaTrader 5
- Mastering the Fibonacci ZigZag Indicator for MetaTrader 5
- Unlocking Trading Insights with Volume Profile + Range v6.0 for MetaTrader 5
- ID Lite Info MA: A Comprehensive Indicator for MetaTrader 5