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 inputuint NumberofBar=1;//Bar number for the signalinputbool SoundON=true;//Enable alertsinputuint NumberofAlerts=2;//Number of alertsinputbool EMailON=false;//Enable mailing the signalinputbool 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 constint Rates_total,// Current number of bars constint Prev_calculated,// Number of bars on the previous tick constdouble &Close[],// Close prices constint &Spread[])// Spread { //--- staticuint 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; doubleAsk=Close[index]; doubleBid=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

Comments 0