Divergence Indicator For MT5

Divergence Indicator For MT5

Table Of Contents:

  1. Divergence Indicator For MT5
  2. Installing the Divergence Indicator For MT5
  3. Parameters of the Divergence Indicator For MT5
  4. Buffers of the Divergence Indicator For MT5
  5. Main Parts Of The Code

The Divergence Indicator For MT5 is a unique tool that analyzes the indicator data and price movement so that it can find the exact price where the indicator value doesn’t coincide with the technical details. Most of the time, the naïve traders don’t know how to filter out the false trading signals. They rely on the traditional risk management approach so that they can accept the losing trades without having any stress. But with the help of this indicator, you can easily asses the anomaly in the technical data and this will help you to stay in the sideline. On the contrary, when the indicator reading completely synchronizes with the manual assessment, you can place the trade with the level of confidence. When you use this tool, make sure you never take too much risk even though you are using one of the most effective ways to find great trades.

FREE Divergence Indicator

Download the FREE Divergence 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


Installing the Divergence 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 divergence.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 Divergence Indicator For MT5

The Divergence Indicator For MT5 has 6 parameters to configure.

input INDMODE ind=MODE_MACD;     //indicator input uint pds=10;               //indicator periods input PRICEMODE f=MODE_CLOSE;    //price field input double dCh=0;              //peak/trough depth minimum (0-1) input uint xshift=0;             //shift signals back to match divergences input int Shift=0;               //horizontal shift of the indicator in bars 

Buffers of the Divergence Indicator For MT5

The Divergence Indicator For MT5 provides 10 buffers.

SetIndexBuffer(0,ExtOpenBuffer,INDICATOR_DATA); SetIndexBuffer(1,ExtHighBuffer,INDICATOR_DATA); SetIndexBuffer(2,ExtLowBuffer,INDICATOR_DATA); SetIndexBuffer(3,ExtCloseBuffer,INDICATOR_DATA); SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX); SetIndexBuffer(5,R1,INDICATOR_CALCULATIONS); SetIndexBuffer(6,R2,INDICATOR_CALCULATIONS); SetIndexBuffer(7,y,INDICATOR_CALCULATIONS); SetIndexBuffer(8,xd,INDICATOR_CALCULATIONS); SetIndexBuffer(9,xu,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[])   { //---- checking for the sufficiency of bars for the calculation    if(BarsCalculated(Ind_Handle) lt rates_total || rates_total lt min_rates_total) return(RESET);  //---- declaration of local variables     int limit,to_copy,bar,CNmb1,CNmb2,CNmb3,CNmb4;    double Pkx1,Pkx2,Trx1,Trx2,Pky1,Pky2,Try1,Try2;    bool Trx,Pkx,Try,Pky;  //---- calculations of the necessary amount of data to be copied and //the starting number limit for the bar recalculation loop    if(prev_calculated gt rates_total || prev_calculated lt =0)// checking for the first start of the indicator calculation      {       limit=rates_total-1-min_rates_total-3; // starting index for the calculation of all bars      }    else      {       limit=rates_total-prev_calculated; // starting index for the calculation of new bars      }     to_copy=limit+1;  //---- copy newly appeared data into the arrays    if(CopyBuffer(Ind_Handle,MAIN_LINE,0,to_copy,y) lt =0) return(RESET);  //---- indexing elements in arrays as timeseries      ArraySetAsSeries(high,true);    ArraySetAsSeries(low,true);    ArraySetAsSeries(close,true);    ArraySetAsSeries(open,true);     for(bar=limit; bar gt =0 && !IsStopped(); bar--)      {       if(f==MODE_CLOSE)         {          xu[bar]=close[bar];          xd[bar]=close[bar];         }       else         {          xu[bar]=high[bar];          xd[bar]=low[bar];         }        ExtOpenBuffer [bar]=0.0;       ExtCloseBuffer[bar]=0.0;       ExtHighBuffer [bar]=0.0;       ExtLowBuffer  [bar]=0.0;      }  //---- main loop of the indicator calculation    for(bar=limit; bar gt =2 && !IsStopped(); bar--)      {       CNmb1=0;       CNmb2=0;       CNmb3=0;       CNmb4=0;        for(int kkk=bar; kkk lt rates_total; kkk++)         {          Pkx=xu[kkk] lt xu[kkk-1] && xu[kkk-1] gt xu[kkk-2] && xu[kkk-1] gt =(xu[kkk]+xu[kkk-2])/2.0*(1.0+fCh);           if(Pkx) CNmb1++;          if(Pkx && CNmb1==1) Pkx1=xu[kkk-1];          if(Pkx && CNmb1==2) Pkx2=xu[kkk-1];           Trx=xd[kkk] gt xd[kkk-1] && xd[kkk-1] lt xd[kkk-2] && xd[kkk-1] lt =(xd[kkk]+xd[kkk-2])/2.0*(1.0-fCh);           if(Trx) CNmb2++;          if(Trx && CNmb2==1) Trx1=xd[kkk-1];          if(Trx && CNmb2==2) Trx2=xd[kkk-1];           Pky=y[kkk] lt y[kkk-1] && y[kkk-1] gt y[kkk-2] && y[kkk-1] gt =(y[kkk]+y[kkk-2])/2.0*(1.0+fCh);           if(Pky) CNmb3++;          if(Pky && CNmb3==1) Pky1=y[kkk-1];          if(Pky && CNmb3==2) Pky2=y[kkk-1];           Try=y[kkk] gt y[kkk-1] && y[kkk-1] lt y[kkk-2] && y[kkk-1] lt =(y[kkk]+y[kkk-2])/2.0*(1.0-fCh);           if(Try) CNmb4++;          if(Try && CNmb4==1) Try1=y[kkk-1];          if(Try && CNmb4==2) Try2=y[kkk-1];           if(CNmb1 gt =2 && CNmb2 gt =2 && CNmb3 gt =2 && CNmb4 gt =2) break;         }        Pkx=xu[bar] lt xu[bar-1] && xu[bar-1] gt xu[bar-2] && xu[bar-1] gt =(xu[bar]+xu[bar-2])/2.0*(1.0+fCh);       Trx=xd[bar] gt xd[bar-1] && xd[bar-1] lt xd[bar-2] && xd[bar-1] lt =(xd[bar]+xd[bar-2])/2.0*(1.0-fCh);       Pky=y[bar] lt y[bar-1] && y[bar-1] gt y[bar-2] && y[bar-1] gt =(y[bar]+y[bar-2])/2.0*(1.0+fCh);       Try=y[bar] gt y[bar-1] && y[bar-1] lt y[bar-2] && y[bar-1] lt =(y[bar]+y[bar-2])/2.0*(1.0-fCh);        R1[bar]=0;       if(Trx && Try && Trx1 lt Trx2 && Try1 gt Try2) R1[bar]=1;        R2[bar]=0;       if(Pkx && Pky && Pkx1 gt Pkx2 && Pky1 lt Pky2) R2[bar]=1;        if(R1[bar]-R2[bar] gt 0)         {          ExtOpenBuffer[bar]=open[bar];          ExtCloseBuffer[bar]=close[bar];          ExtHighBuffer[bar]=high[bar];          ExtLowBuffer[bar]=low[bar];          if(close[bar] gt open[bar]) ExtColorBuffer[bar]=3;          else ExtColorBuffer[bar]=2;         }        if(R1[bar]-R2[bar] lt 0)         {          ExtOpenBuffer[bar]=open[bar];          ExtCloseBuffer[bar]=close[bar];          ExtHighBuffer[bar]=high[bar];          ExtLowBuffer[bar]=low[bar];          if(open[bar] gt close[bar]) ExtColorBuffer[bar]=0;          else ExtColorBuffer[bar]=1;         }      } //----         return(rates_total);   } //+------------------------------------------------------------------+ 


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.