Pearson coefficient Indicator For MT5

Pearson coefficient Indicator For MT5

The Pearson coefficient Indicator For MT5 deals with price correlation, standard deviation, and coefficient index. The volatility of the market is determined by the bold curve in the indicator window and the traders should be expecting massive spikes when the volatility curve is at the extreme point. On the contrary, the green and red color dashed line is used to show the strength of the bulls and bears. This tool is mostly used by the position trader so that they can maximize the profit by riding the major trend.

FREE Pearson coefficient Indicator

Download the FREE Pearson coefficient 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 Pearson coefficient 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 Pearson coeficcient.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 Pearson coefficient Indicator For MT5

The Pearson coefficient Indicator For MT5 has 5 parameters to configure.

input string             inpSymbol      = "";          // Second symbol
input int                inpPeriod      = 30;          // Period
input int                inpLag         = 1;           // Lag of the second symbol
input ENUM_APPLIED_PRICE inpPrice       = PRICE_CLOSE; // Price
input enColorMode        inpColorMode   = col_onOuter; // Change color mode

Buffers of the Pearson coefficient Indicator For MT5

The Pearson coefficient Indicator For MT5 provides 7 buffers.


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(prev_calculated);

   double pers = MathSqrt(inpPeriod);
      MqlRates _ratesf[1];
      MqlRates _ratesl[1];
      for(int i=(int)MathMax(prev_calculated-1,0); i lt rates_total && !_StopFlag; i++)
         int _ratesfCopied =               CopyRates(_Symbol   ,0,time[i       ],1,_ratesf);
         int _rateslCopied = (i gt =inpLag) ? CopyRates(_forSymbol,0,time[i-inpLag],1,_ratesl) : CopyRates(_forSymbol,0,time[i],1,_ratesl);
         diff[i] = (_ratesfCopied == 1) ? getPrice(inpPrice,_ratesf) : 0;
         difl[i] = (_rateslCopied == 1) ? getPrice(inpPrice,_ratesl) : 0;
            double dev1 = iDeviation(diff,inpPeriod,i);
            double dev2 = iDeviation(difl,inpPeriod,i);
                   val[i]  = (dev1!=0 && dev2!=0) ? iCovariance(diff,difl,inpPeriod,i)/(dev1*dev2) : 0;
            double pe      = 0.6745*(1.0-val[i]*val[i])/pers;
            flup[i] =  6.0*pe;
            fldn[i] = -6.0*pe;
            flmi[i] =       0;
            switch (inpColorMode)
               case col_onOuter : valc[i] = (val[i] gt flup[i]) ? 2 :(val[i] lt fldn[i]) ? 1 : 0; break;
               case col_onZero  : valc[i] = (val[i] gt flmi[i]) ? 2 :(val[i] lt flmi[i]) ? 1 : (i gt 0) ? valc[i-1]: 0; break;
//| Custom functions                                                 |
double iDeviation(double& array[], int size, int i, bool isSample = false)
   double avg = array[i]; for (int k=1; k lt size && (i-k) gt =0; k++) avg  += array[i-k];  avg /= (double)size;
   double sum = 0;
      for (int k=0; k lt size&& (i-k) gt =0; k++) sum += (array[i-k]-avg)*(array[i-k]-avg);
      if (isSample)         
      else  return(MathSqrt(sum/(double)(size)));
double iCovariance(double& indep[], double& depen[], int size, int i, bool isSample = false)
   double avgi = indep[i]; for (int k=1; k lt size && (i-k) gt =0; k++) avgi += indep[i-k]; avgi /= size;
   double avgd = depen[i]; for (int k=1; k lt size && (i-k) gt =0; k++) avgd += depen[i-k]; avgd /= size;
   double sum = 0;
      for (int k=0; k lt size && (i-k) gt =0; k++) sum += (indep[i-k]-avgi)*(depen[i-k]-avgd);

      if (isSample)         
      else  return(sum/(size));
double getPrice(ENUM_APPLIED_PRICE tprice, MqlRates& _rates[])
         case PRICE_CLOSE:     return(_rates[0].close);
         case PRICE_OPEN:      return(_rates[0].open);
         case PRICE_HIGH:      return(_rates[0].high);
         case PRICE_LOW:       return(_rates[0].low);
         case PRICE_MEDIAN:    return((_rates[0].high+_rates[0].low)/2.0);
         case PRICE_TYPICAL:   return((_rates[0].high+_rates[0].low+_rates[0].close)/3.0);
         case PRICE_WEIGHTED:  return((_rates[0].high+_rates[0].low+_rates[0].close+_rates[0].close)/4.0);


About Me

I'm Mike Semlitsch the owner of 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.