Phase accumulation adaptive bandpass filter Indicator For MT5

Phase accumulation adaptive bandpass filter Indicator For MT5

The Phase accumulation adaptive bandpass filter Indicator For MT5 uses the Hilbert transform in a phase accumulation mode for John Ehlers bandpass filter period. This creates an adaptive market indicator. It filters both low frequency price trends and high frequency noise to generate trading signals in the form of indicator color change.

1. Go long when the indicator switches its color to Medium Sea Green.

2. Go short when the Phase accumulation adaptive bandpass filter Indicator For MT5 changes its color to Orange Red.

FREE Phase accumulation adaptive bandpass filter Indicator

Download the FREE Phase accumulation adaptive bandpass filter Indicator for MT5.

To receive my email 100% sure: 
Put my email on your whitelist!

 

Partially Automated Trading Besides Your Day Job

Alerts In Real-Time When Divergences Occur

My Recommended MT4/MT5 Broker

 

Installing the Phase accumulation adaptive bandpass filter Indicator For MT5

After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file Bandpass filter (pa).mq5 into the folder MQL5\Indicators of your MT5 installation. After that please restart MT5 and then you will be able to see the indicator in the list of indicators.

Parameters of the Phase accumulation adaptive bandpass filter Indicator For MT5

The Phase accumulation adaptive bandpass filter Indicator For MT5 has 4 parameters to configure.

input double              inpCyclesPeriod = 2;            // Cycles period
input double              inpCyclesFilter = 0;            // Cycles filter (<=1 for no filtering)
input double              inpDelta        = 0.5;          // Delta
input ENUM_APPLIED_PRICE  inpPrice        = PRICE_MEDIAN; // Price

Buffers of the Phase accumulation adaptive bandpass filter Indicator For MT5

The Phase accumulation adaptive bandpass filter Indicator For MT5 provides 2 buffers.

SetIndexBuffer(0,val);
SetIndexBuffer(1,valc,INDICATOR_COLOR_INDEX);

Main Parts Of The Code

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[])
{
   struct sBandPassStruct
   {
      double price;
      double bandpass;
   };
   static sBandPassStruct m_array[];
   static int m_arraySize = -1;
          if (m_arraySize lt rates_total)
          {
              m_arraySize = ArrayResize(m_array,rates_total+500); if (m_arraySize lt rates_total) return(0);
          }

   //
   //---
   //
                                    
   int i=prev_calculated-1; if (i lt 0) i=0; for (; i lt rates_total && !_StopFlag; i++)
   {
      _setPrice(inpPrice,m_array[i].price,i);
      double _phasePeriod = iHilbertPhase(m_array[i].price,g_cycleFilter,inpCyclesPeriod,i,rates_total);
      double gamma     = 1.0 / MathCos(4.0*M_PI*inpDelta/_phasePeriod);
             g_beta    = MathCos(2.0*M_PI/_phasePeriod);
             g_alpha   = gamma -MathSqrt(gamma*gamma-1.0);
      
         m_array[i].bandpass = (i gt 1) ? 0.5*(1.0-g_alpha)*(m_array[i].price-m_array[i-2].price)+g_beta*(1.0+g_alpha)*m_array[i-1].bandpass-g_alpha*m_array[i-2].bandpass : m_array[i].price;
         val[i]  = m_array[i].bandpass;
         valc[i] = (val[i] gt 0) ? 1 : (val[i] lt 0) ? 2 : 0;
   }               
   return(i);        
}

//------------------------------------------------------------------
// Custom functions
//------------------------------------------------------------------
//
//---
//

double iHilbertPhase(double price, double filter, double cyclesToReach, int i, int bars)
{
   struct iHilbertPhaseStruct
      {
         double price;
         double smooth;
         double detrender;
         double period;
         double phase;
         double deltaPhase;
         double Q1;
         double I1;
      };       
   static iHilbertPhaseStruct m_array[];
   static int m_arraySize = -1;
          if (m_arraySize lt bars)
          {
               m_arraySize=ArrayResize(m_array,bars+500); if (m_arraySize lt bars) return(price);
          }
   
      
   //
   //---
   //

      m_array[i].price = price; 
         if (i lt 6) { 
                     m_array[i].period     = 1;  
                     m_array[i].deltaPhase = 7;  
                     m_array[i].smooth     = m_array[i].Q1 = m_array[i].I1 = price; 
                     return(1); 
                  }
                  cyclesToReach *= 360.0;

      //
      //---
      //
      
      #define _calcComp(_ind) ((0.0962*m_array[i]._ind + 0.5769*m_array[i-2]._ind - 0.5769*m_array[i-4]._ind - 0.0962*m_array[i-6]._ind) * (0.075*m_array[i-1].period + 0.54))

         m_array[i].smooth     = (4.0*m_array[i].price+3.0*m_array[i-1].price+2.0*m_array[i-2].price+m_array[i-3].price)/10.0;
         m_array[i].detrender  = _calcComp(smooth);
         m_array[i].Q1         = 0.15*_calcComp(detrender)  +0.85*m_array[i-1].Q1;
         m_array[i].I1         = 0.15*m_array[i-3].detrender+0.85*m_array[i-1].I1;

         //
         //---
         //

         m_array[i].phase = (m_array[i].I1!=0) ? 180.0/M_PI*MathArctan(MathAbs(m_array[i].Q1/m_array[i].I1)) : m_array[i-1].phase;
            if (m_array[i].I1 lt 0 && m_array[i].Q1 gt 0) m_array[i].phase = 180.0-m_array[i].phase;
            if (m_array[i].I1 lt 0 && m_array[i].Q1 lt 0) m_array[i].phase = 180.0+m_array[i].phase;
            if (m_array[i].I1 gt 0 && m_array[i].Q1 lt 0) m_array[i].phase = 360.0-m_array[i].phase;

         //
         //---
         //
                        
         m_array[i].deltaPhase = m_array[i-1].phase-m_array[i].phase;

         if (m_array[i-1].phase lt 90.0 && m_array[i].phase gt 270.0) m_array[i].deltaPhase = 360.0+m_array[i-1].phase-m_array[i].phase;
         if (m_array[i].deltaPhase gt 60.0) m_array[i].deltaPhase = 60.0;
         if (m_array[i].deltaPhase lt  7.0) m_array[i].deltaPhase =  7.0;
      
         //
         //---
         //
         
         double phaseSum = m_array[i].deltaPhase; int k=1; for (; phaseSum lt cyclesToReach && i gt =k; k++) phaseSum += m_array[i-k].deltaPhase;
           m_array[i].period = m_array[i-1].period+filter*(k-m_array[i-1].period);
   return (m_array[i].period);
}

 

About Me

I'm Mike Semlitsch the owner of PerfectTrendSystem.com. My trading career started in 2007. Since 2013 I have helped thousands of traders to take their trading to the next level. Many of them are now constantly profitable traders. 

The following performance was achieved by me while trading live in front of hundreds of my clients:

Connect With Me:  

Results From 5 Months!
This service starts soon! Be the first who get's notified when it begins!

This FREE Indicator Can Transform
Your Trading!

FREE Indicator + Telegram Group


Request the Ultimate Double Top/Bottom Indicator which is used by 10,000+ traders.