Home Technical Indicator Post

Unlock Trading Insights with the Balance of Power Histogram Alert for MT5

Attachments
16403.zip (22.71 KB, Download 0 times)

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:

  1. New input parameters have been added to customize your alerts:
  2. //---- 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
    
  3. Three new functions have been added: BuySignal(), SellSignal(), and GetStringTimeframe(). Here’s a peek at the BuySignal function:
  4. //+------------------------------------------------------------------+
    //| 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);
         }
    //---
      }
    //+------------------------------------------------------------------+
    
  5. Calls to BuySignal() and SellSignal() functions have been added after the indicator calculation cycles in the OnCalculate() block:
  6. //---     
       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 on Chart

Balance of Power Histogram Alert Generating Alerts

Balance of Power Histogram Alert Generating Alerts

Related Posts

Comments (0)