PDFma Indicator For MT5

PDFma Indicator For MT5

The PDFma Indicator For MT5 works on the principle of weighted moving average and digital filter. Those who have strong knowledge about this indicator can easily make a decent profit by predicting the direction of the trend. When the price is trending up, you will notice a green color moving average and a grey color shadow will be there just below the candlestick. When the price will slope downward, you will notice the signal curve is changing its color orange. The grey color cloud will be trading above the candlestick. In order to improve your trade execution process, you must learn to deal with the higher time frame data when you use this tool. If possible look for the candlestick pattern to find reliable trade setups. Once you find a perfect trade, analyze the quality of the signals by assessing the reading of this PDFma indicator.

FREE PDFma Indicator

Download the FREE PDFma 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 PDFma 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 Pdfma.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 PDFma Indicator For MT5

The PDFma Indicator For MT5 has 17 parameters to configure.

input ENUM_TIMEFRAMES TimeFrame       = PERIOD_CURRENT; // Time frame
input int             MaPeriod        = 25;             // PDFMA period
input double          MaVariance      =  1;             // PDFMA variance
input double          MaMean          =  0;             // PDFMA mean
input enPrices        MaPrice         = pr_close;       // Price
input chgColor        ColorOn         = cc_onLevel;     // Color change on :
input enLevelType     LevelType       = lvl_floa;       // Level type
input int             LevelPeriod     = 25;             // Levels period
input double          LevelUp         = 90;             // Upper level %
input double          LevelDown       = 10;             // Lower level %
input bool            AlertsOn        = false;          // Turn alerts on?
input bool            AlertsOnCurrent = true;           // Alert on current bar?
input bool            AlertsMessage   = true;           // Display messageas on alerts?
input bool            AlertsSound     = false;          // Play sound on alerts?
input bool            AlertsEmail     = false;          // Send email on alerts?
input bool            AlertsNotify    = false;          // Send push notification on alerts?
input bool            Interpolate     = true;           // Interpolate when in multi time frame mode?

Buffers of the PDFma Indicator For MT5

The PDFma Indicator For MT5 provides 6 buffers.

SetIndexBuffer(0,fup ,INDICATOR_DATA);
SetIndexBuffer(1,fdn ,INDICATOR_DATA);
SetIndexBuffer(2,mid ,INDICATOR_DATA);
SetIndexBuffer(3,val ,INDICATOR_DATA);
SetIndexBuffer(4,valc,INDICATOR_COLOR_INDEX);
SetIndexBuffer(5,count,INDICATOR_CALCULATIONS);

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[])
{ 
   if (Bars(_Symbol,_Period) lt rates_total) return(-1);
   
      //
      //
      //
      //
      //
      
      if (timeFrame!=_Period)
      {
         double result[]; datetime currTime[],nextTime[]; 
            if (!timeFrameCheck(timeFrame,time))         return(0);
            if (_mtfHandle==INVALID_HANDLE) _mtfHandle = _mtfCall;
            if (_mtfHandle==INVALID_HANDLE)              return(0);
            if (CopyBuffer(_mtfHandle,5,0,1,result)==-1) return(0); 
      
                //
                //
                //
                //
                //
              
                #define _mtfRatio PeriodSeconds(timeFrame)/PeriodSeconds(_Period)
                int k,n,i = MathMin(MathMax(prev_calculated-1,0),MathMax(rates_total-(int)result[0]*_mtfRatio-1,0));
                for (; i lt rates_total && !_StopFlag; i++ )
                {
                  #define _mtfCopy(_buff,_buffNo) if (CopyBuffer(_mtfHandle,_buffNo,time[i],1,result)==-1) break; _buff[i] = result[0]
                          _mtfCopy(fup ,0);
                          _mtfCopy(fdn ,1);
                          _mtfCopy(mid ,2);
                          _mtfCopy(val ,3);
                          _mtfCopy(valc,4);
                   
                          //
                          //
                          //
                          //
                          //
                   
                          #define _mtfInterpolate(_buff) _buff[i-k] = _buff[i]+(_buff[i-n]-_buff[i])*k/n
                          if (!Interpolate) continue;  CopyTime(_Symbol,timeFrame,time[i  ],1,currTime); 
                              if (i lt (rates_total-1)) { CopyTime(_Symbol,timeFrame,time[i+1],1,nextTime); if (currTime[0]==nextTime[0]) continue; }
                              for(n=1; (i-n) gt  0 && time[i-n]  gt = currTime[0]; n++) continue;	
                              for(k=1; (i-k) gt =0 && k lt n; k++)
                              {
                                  _mtfInterpolate(fup);
                                  _mtfInterpolate(fdn);
                                  _mtfInterpolate(mid);
                                  _mtfInterpolate(val);
                              }                                 
                }
                return(i);
      }
         
   //
   //
   //
   //
   //
   
   int    levelType  = (LevelPeriod gt 1) ? LevelType : lvl_fixed; 
   int    colorOn    = (levelType!=lvl_fixed) ? ColorOn : cc_onSlope; 
   double maVariance = MathMax(MaVariance,0.01);
   double maMean     = MathMax(MathMin(MaMean,1.0),-1.0);   
   int i=(int)MathMax(prev_calculated-1,0); for (; i lt rates_total && !_StopFlag; i++)
   {
      double price = getPrice(MaPrice,open,close,high,low,i,rates_total);
             val[i] = iPdfma(price,MaPeriod,maVariance,maMean,i,rates_total);
         
         //
         //
         //
         //
         //

            switch (levelType)
            {
               case lvl_fixed : 
                     fup[i] = val[i];
                     fdn[i] = val[i];
                     mid[i] = val[i];
                     break;
               case lvl_floa :                     
                     {               
                        int    start = MathMax(i-LevelPeriod+1,0);
                        double min   = val[ArrayMinimum(val,start,LevelPeriod)];
                        double max   = val[ArrayMaximum(val,start,LevelPeriod)];
                        double range = max-min;
                           fup[i] = min+LevelUp  *range/100.0;
                           fdn[i] = min+LevelDown*range/100.0;
                           mid[i] = (fup[i]+fdn[i])*0.5;
                           break;
                     }
               default :                                                
                     fup[i] = iQuantile(val[i],LevelPeriod, LevelUp               ,i,rates_total);
                     fdn[i] = iQuantile(val[i],LevelPeriod, LevelDown             ,i,rates_total);
                     mid[i] = iQuantile(val[i],LevelPeriod,(LevelUp+LevelDown)*0.5,i,rates_total);
                     break;
            }               
            switch(colorOn)
            {
               case cc_onLevel:  valc[i] = (val[i] gt fup[i])  ? 1 : (val[i] lt fdn[i])  ? 2 : (val[i] gt fdn[i] && val[i] lt fup[i]) ? 0 : (i gt 0) ? valc[i-1] : 0; break;
               case cc_onMiddle: valc[i] = (val[i] gt mid[i])  ? 1 : (val[i] lt mid[i])  ? 2 : 0; break;
               default :         valc[i] = (i gt 0) ? (val[i] gt val[i-1]) ? 1 : (val[i] lt val[i-1]) ? 2 : valc[i-1] : 0;
            }                  
   }
   count[rates_total-1] = MathMax(rates_total-prev_calculated+1,1);
   manageAlerts(time,valc,rates_total);
   return(rates_total);
}

//------------------------------------------------------------------
//                                                                  
//------------------------------------------------------------------
//
//
//
//
//

#define _pdfmaInstances 1
double  _pdfmaWork[][_pdfmaInstances];
double  _pdfmaCoeffs[][_pdfmaInstances];
double iPdfma(double value, int period, double variance, double mean, int i, int bars, int instanceNo=0)
{
   if (ArrayRange(_pdfmaWork,0)  != bars)   ArrayResize(_pdfmaWork,bars);
   if (ArrayRange(_pdfmaCoeffs,0) lt period+1) ArrayResize(_pdfmaCoeffs,period+1);
   if (_pdfmaCoeffs[period][instanceNo]!=period)
   {
      double step = M_PI/(period-1); for(int k=0; k lt period; k++) _pdfmaCoeffs[k][instanceNo] = iPdf(k*step,variance,mean*M_PI);   
                                                                 _pdfmaCoeffs[period][instanceNo]=period;
   }                                                                     
   
   //
   //
   //
   //
   //
   
   _pdfmaWork[i][instanceNo] = value;
      double sumw = _pdfmaCoeffs[0][instanceNo];
      double sum  = _pdfmaCoeffs[0][instanceNo]*value;

      for(int k=1; k lt period && (i-k) gt =0; k++)
      {
         double weight = _pdfmaCoeffs[k][instanceNo]*value;
                sumw  += weight;
                sum   += weight*_pdfmaWork[i-k][instanceNo];  
      }             
      return(sum/sumw);
}
double iPdf(double x, double variance=1.0, double mean=0) { return((1.0/MathSqrt(2*M_PI*MathPow(variance,2))*MathExp(-MathPow(x-mean,2)/(2*MathPow(variance,2))))); }

//-------------------------------------------------------------------
//                                                                  
//-------------------------------------------------------------------
//
//
//
//
//

#define _quantileInstances 1
double _sortQuant[];
double _workQuant[][_quantileInstances];

double iQuantile(double value, int period, double qp, int i, int bars, int instanceNo=0)
{
   if (ArrayRange(_workQuant,0)!=bars) ArrayResize(_workQuant,bars);   _workQuant[i][instanceNo]=value; if (period lt 1) return(value);
   if (ArraySize(_sortQuant)!=period)  ArrayResize(_sortQuant,period); 
            int k=0; for (; k lt period && (i-k) gt =0; k++) _sortQuant[k] = _workQuant[i-k][instanceNo];
                     for (; k lt period            ; k++) _sortQuant[k] = 0;
                     ArraySort(_sortQuant);

   //
   //
   //
   //
   //
   
   double index = (period-1.0)*qp/100.00;
   int    ind   = (int)index;
   double delta = index - ind;
   if (ind == NormalizeDouble(index,5))
         return(            _sortQuant[ind]);
   else  return((1.0-delta)*_sortQuant[ind]+delta*_sortQuant[ind+1]);
}   

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
//

#define _pricesInstances 1
#define _pricesSize      4
double workHa[][_pricesInstances*_pricesSize];
double getPrice(int tprice, const double& open[], const double& close[], const double& high[], const double& low[], int i,int _bars, int instanceNo=0)
{
  if (tprice gt =pr_haclose)
   {
      if (ArrayRange(workHa,0)!= _bars) ArrayResize(workHa,_bars); instanceNo*=_pricesSize;
         
         //
         //
         //
         //
         //
         
         double haOpen;
         if (i gt 0)
                haOpen  = (workHa[i-1][instanceNo+2] + workHa[i-1][instanceNo+3])/2.0;
         else   haOpen  = (open[i]+close[i])/2;
         double haClose = (open[i] + high[i] + low[i] + close[i]) / 4.0;
         double haHigh  = MathMax(high[i], MathMax(haOpen,haClose));
         double haLow   = MathMin(low[i] , MathMin(haOpen,haClose));

         if(haOpen   lt haClose) { workHa[i][instanceNo+0] = haLow;  workHa[i][instanceNo+1] = haHigh; } 
         else                 { workHa[i][instanceNo+0] = haHigh; workHa[i][instanceNo+1] = haLow;  } 
                                workHa[i][instanceNo+2] = haOpen;
                                workHa[i][instanceNo+3] = haClose;
         //
         //
         //
         //
         //
         
         switch (tprice)
         {
            case pr_haclose:     return(haClose);
            case pr_haopen:      return(haOpen);
            case pr_hahigh:      return(haHigh);
            case pr_halow:       return(haLow);
            case pr_hamedian:    return((haHigh+haLow)/2.0);
            case pr_hamedianb:   return((haOpen+haClose)/2.0);
            case pr_hatypical:   return((haHigh+haLow+haClose)/3.0);
            case pr_haweighted:  return((haHigh+haLow+haClose+haClose)/4.0);
            case pr_haaverage:   return((haHigh+haLow+haClose+haOpen)/4.0);
            case pr_hatbiased:
               if (haClose gt haOpen)
                     return((haHigh+haClose)/2.0);
               else  return((haLow+haClose)/2.0);        
            case pr_hatbiased2:
               if (haClose gt haOpen)  return(haHigh);
               if (haClose lt haOpen)  return(haLow);
                                    return(haClose);        
         }
   }
   
   //
   //
   //
   //
   //
   
   switch (tprice)
   {
      case pr_close:     return(close[i]);
      case pr_open:      return(open[i]);
      case pr_high:      return(high[i]);
      case pr_low:       return(low[i]);
      case pr_median:    return((high[i]+low[i])/2.0);
      case pr_medianb:   return((open[i]+close[i])/2.0);
      case pr_typical:   return((high[i]+low[i]+close[i])/3.0);
      case pr_weighted:  return((high[i]+low[i]+close[i]+close[i])/4.0);
      case pr_average:   return((high[i]+low[i]+close[i]+open[i])/4.0);
      case pr_tbiased:   
               if (close[i] gt open[i])
                     return((high[i]+close[i])/2.0);
               else  return((low[i]+close[i])/2.0);        
      case pr_tbiased2:   
               if (close[i] gt open[i]) return(high[i]);
               if (close[i] lt open[i]) return(low[i]);
                                     return(close[i]);        
   }
   return(0);
}


//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

 

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.