Peak Lines by Price Histogram Indicator For MT5

Peak Lines by Price Histogram Indicator For MT5

The Peak Lines by Price Histogram Indicator For MT5 is a very useful technical indicator to have as a trader or technical chartist because what it does is that it outputs and displays relevant support and resistance lines or zones by means of a price histogram which is based on a simplified calculation that is not so resource intensive. This indicator displays a set of different colored lines - gold, red, magenta and blue - the gold line marks the peaks of a 1-day histogram, the red line are the peaks of short term histogram, the magenta line are the peaks of a medium term histogram and the blue shows the peaks of a long term histogram. This saves a lot of time in many ways because the trader does not have to spend their precious time drawing their own resistance and support lines which may not always be effective or accurate - this indicator automatically draws support and resistance lines for the trader. This creates a lot of room for the trader to focus on other critical aspects of their trading and analyzing activities - furthermore this indicator has three input variables namely the Bin range of price histogram, Short term period (day) input parameter and the long term period (day) input parameter to name only but a few.

FREE Peak Lines by Price Histogram Indicator

Download the FREE Peak Lines by Price Histogram 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 Peak Lines by Price Histogram 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 peak_lines_by_price_histogram.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 Peak Lines by Price Histogram Indicator For MT5

The Peak Lines by Price Histogram Indicator For MT5 has 6 parameters to configure.

input double InpBinRange=2.5;       // Bin range of price histogram
input  int InpCalcTime=4;           // Calculation Time(hour)
input  int InpShortTermPeriod =3;   // Short term period(day)
input  int InpMediumTermPeriod=7;   // Medium term period(day)
input  int InpLongTermPeriod =26;   // Long term period(day)
input bool InpUsingVolumeWeight=true;   // Using TickVolume

Buffers of the Peak Lines by Price Histogram Indicator For MT5

The Peak Lines by Price Histogram Indicator For MT5 provides 32 buffers.

SetIndexBuffer(0,Day1Buffer,INDICATOR_DATA);
SetIndexBuffer(1,Day2Buffer,INDICATOR_DATA);
SetIndexBuffer(2,Short1Buffer,INDICATOR_DATA);
SetIndexBuffer(3,Short2Buffer,INDICATOR_DATA);
SetIndexBuffer(4,Medium1Buffer,INDICATOR_DATA);
SetIndexBuffer(5,Medium2Buffer,INDICATOR_DATA);
SetIndexBuffer(6,Long1Buffer,INDICATOR_DATA);
SetIndexBuffer(7,Long2Buffer,INDICATOR_DATA);
SetIndexBuffer(8,D1Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(9,D2Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(10,D3Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(11,D4Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(12,S1Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(13,S2Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(14,S3Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(15,S4Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(16,M1Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(17,M2Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(18,M3Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(19,M4Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(20,M5Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(21,M6Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(22,M7Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(23,M8Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(24,L1Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(25,L2Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(26,L3Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(27,L4Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(28,L5Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(29,L6Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(30,L7Buffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(31,L8Buffer,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[])
  {
//---
   int i,first;
//--- check for bars count
   if(rates_total lt =min_rates_total)
      return(0);
//---
   first=min_rates_total-1;
   if(first+1 lt prev_calculated) first=prev_calculated-2;
//---- Main calculation loop of the indicator
   for(i=first; i lt rates_total && !IsStopped(); i++)
     {
      MqlDateTime tm0,tm1;
      TimeToStruct(time[i],tm0);
      TimeToStruct(time[i-1],tm1);
      bool is_update=false;
      if(!tm0.hour != tm0.hour && tm0.hour == InpCalcTime && tm0.hour == InpCalcTime)
        {
         int d1_peaks[];
         int st_peaks[];
         int mt_peaks[];
         int lt_peaks[];
         bool ok=calc_ds_peaks(d1_peaks,st_peaks,time[i]);
         ok=ok && calc_ml_peaks(lt_peaks,mt_peaks,time[i]);
         if(ok)
           {
            int d1_sz=ArraySize(d1_peaks);
            if(d1_sz gt 0)D1Buffer[i]=d1_peaks[0]*_Point; else D1Buffer[i]=0;
            if(d1_sz gt 1)D2Buffer[i]=d1_peaks[1]*_Point; else D2Buffer[i]=0;
            if(d1_sz gt 2)D3Buffer[i]=d1_peaks[2]*_Point; else D3Buffer[i]=0;
            if(d1_sz gt 3)D4Buffer[i]=d1_peaks[3]*_Point; else D4Buffer[i]=0;
            int st_sz=ArraySize(st_peaks);
            if(st_sz gt 0)S1Buffer[i]=st_peaks[0]*_Point; else S1Buffer[i]=0;
            if(st_sz gt 1)S2Buffer[i]=st_peaks[1]*_Point; else S2Buffer[i]=0;
            if(st_sz gt 2)S3Buffer[i]=st_peaks[2]*_Point; else S3Buffer[i]=0;
            if(st_sz gt 3)S4Buffer[i]=st_peaks[3]*_Point; else S4Buffer[i]=0;
            int mt_sz=ArraySize(mt_peaks);
            if(mt_sz gt 0)M1Buffer[i]=mt_peaks[0]*_Point; else M1Buffer[i]=0;
            if(mt_sz gt 1)M2Buffer[i]=mt_peaks[1]*_Point; else M2Buffer[i]=0;
            if(mt_sz gt 2)M3Buffer[i]=mt_peaks[2]*_Point; else M3Buffer[i]=0;
            if(mt_sz gt 3)M4Buffer[i]=mt_peaks[3]*_Point; else M4Buffer[i]=0;
            if(mt_sz gt 4)M5Buffer[i]=mt_peaks[4]*_Point; else M5Buffer[i]=0;
            if(mt_sz gt 5)M6Buffer[i]=mt_peaks[5]*_Point; else M6Buffer[i]=0;
            if(mt_sz gt 6)M7Buffer[i]=mt_peaks[6]*_Point; else M7Buffer[i]=0;
            if(mt_sz gt 7)M8Buffer[i]=mt_peaks[7]*_Point; else M8Buffer[i]=0;
            int lt_sz=ArraySize(lt_peaks);
            if(lt_sz gt 0)L1Buffer[i]=lt_peaks[0]*_Point; else L1Buffer[i]=0;
            if(lt_sz gt 1)L2Buffer[i]=lt_peaks[1]*_Point; else L2Buffer[i]=0;
            if(lt_sz gt 2)L3Buffer[i]=lt_peaks[2]*_Point; else L3Buffer[i]=0;
            if(lt_sz gt 3)L4Buffer[i]=lt_peaks[3]*_Point; else L4Buffer[i]=0;
            if(lt_sz gt 4)L5Buffer[i]=lt_peaks[4]*_Point; else L5Buffer[i]=0;
            if(lt_sz gt 5)L6Buffer[i]=lt_peaks[5]*_Point; else L6Buffer[i]=0;
            if(lt_sz gt 6)L7Buffer[i]=lt_peaks[6]*_Point; else L7Buffer[i]=0;
            if(lt_sz gt 7)L8Buffer[i]=lt_peaks[7]*_Point; else L8Buffer[i]=0;
            is_update=true;
           }
        }
      if(!is_update)
        {
         D1Buffer[i]=0;  D2Buffer[i]=0;  D3Buffer[i]=0;  D4Buffer[i]=0;
         S1Buffer[i]=0;  S2Buffer[i]=0;  S3Buffer[i]=0;  S4Buffer[i]=0;
         M1Buffer[i]=0;  M2Buffer[i]=0;  M3Buffer[i]=0;  M4Buffer[i]=0;
         M5Buffer[i]=0;  M6Buffer[i]=0;  M7Buffer[i]=0;  M8Buffer[i]=0;
         L1Buffer[i]=0;  L2Buffer[i]=0;  L3Buffer[i]=0;  L4Buffer[i]=0;
         L5Buffer[i]=0;  L6Buffer[i]=0;  L7Buffer[i]=0;  L8Buffer[i]=0;
        }
     }
//---
   for(i=first; i lt rates_total && !IsStopped(); i++)
     {
      //--- pivot point 
      double h[];
      double l[];
      double c[];
      CopyHigh(Symbol(),PERIOD_H1,time[i],PivotHour,h);
      CopyLow(Symbol(),PERIOD_H1,time[i],PivotHour,l);
      CopyClose(Symbol(),PERIOD_H1,time[i],1,c);
      double hi=h[ArrayMaximum(h)];
      double lo=l[ArrayMinimum(l)];
      double cl=c[0];
      //---
      double pp=(cl+hi+lo)/3;
      double s1=pp*2-hi;
      double r1=pp*2-lo;
      double s2 = pp - (r1-s1);
      double r2 =(pp -s1)+r1;
      //---
      set_1d_peeks(s2,r2,i);
      set_st_peeks(s2,r2,i);
      set_mt_peeks(s2,r2,i);
      set_lt_peeks(s2,r2,i);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| set 1 day peak                                                   |
//+------------------------------------------------------------------+
void set_1d_peeks(double s2,double r2,int i)
  {
   int d1cnt=0;
//--- 1day peek line is important 
   if(D1Buffer[i] gt 0) Day1Buffer[i]=D1Buffer[i]; else Day1Buffer[i]=Day1Buffer[i-1];
   d1cnt++;
//---
   if(s2 lt =D2Buffer[i] && D2Buffer[i] lt =r2)
     {
      if(d1cnt==0) Day1Buffer[i]=D2Buffer[i];  else Day2Buffer[i]=D2Buffer[i];
      d1cnt++;
     }
   if(d1cnt lt 2 && s2 lt =D3Buffer[i] && D3Buffer[i] lt =r2)
     {
      if(d1cnt==0) Day1Buffer[i]=D3Buffer[i];  else Day2Buffer[i]=D3Buffer[i];
      d1cnt++;
     }
   if(d1cnt lt 2 && s2 lt =D4Buffer[i] && D4Buffer[i] lt =r2)
     {
      if(d1cnt==0) Day1Buffer[i]=D4Buffer[i];  else Day2Buffer[i]=D4Buffer[i];
      d1cnt++;
     }
   if(d1cnt lt 2)Day2Buffer[i]=Day2Buffer[i-1];
  }
//+------------------------------------------------------------------+
//| set short term peak                                              |
//+------------------------------------------------------------------+
void set_st_peeks(double s2,double r2,int i)
  {
//---
   int s_cnt=0;
//--- 1day peak lines
   if(s2 lt =S1Buffer[i] && S1Buffer[i] lt =r2)
     {
      Short1Buffer[i]=S1Buffer[i];
      s_cnt++;
     }
   if(s2 lt =S2Buffer[i] && S2Buffer[i] lt =r2)
     {
      if(s_cnt==0) Short1Buffer[i]=S2Buffer[i]; else Short2Buffer[i]=S2Buffer[i];
      s_cnt++;
     }
   if(s_cnt lt 2 && s2 lt =S3Buffer[i] && S3Buffer[i] lt =r2)
     {
      if(s_cnt==0) Short1Buffer[i]=S3Buffer[i]; else Short2Buffer[i]=S3Buffer[i];
      s_cnt++;
     }
   if(s_cnt lt 2 && s2 lt =S4Buffer[i] && S4Buffer[i] lt =r2)
     {
      if(s_cnt==0) Short1Buffer[i]=S4Buffer[i]; else Short2Buffer[i]=S4Buffer[i];
      s_cnt++;
     }
   if(s_cnt lt 1)Short1Buffer[i] = Short1Buffer[i-1];
   if(s_cnt lt 2)Short2Buffer[i] = Short2Buffer[i-1];
  }
//+------------------------------------------------------------------+
//| set medium term peak                                             |
//+------------------------------------------------------------------+
void set_mt_peeks(double s2,double r2,int i)
  {
   int m_cnt=0;
   if(s2 lt =M1Buffer[i] && M1Buffer[i] lt =r2)
     {
      Medium1Buffer[i]=M1Buffer[i];
      m_cnt++;
     }
   if(s2 lt =M2Buffer[i] && M2Buffer[i] lt =r2)
     {
      if(m_cnt==0) Medium1Buffer[i]=M2Buffer[i]; else Medium2Buffer[i]=M2Buffer[i];
      m_cnt++;
     }
   if(m_cnt lt 2 && s2 lt =M3Buffer[i] && M3Buffer[i] lt =r2)
     {
      if(m_cnt==0) Medium1Buffer[i]=M3Buffer[i]; else Medium2Buffer[i]=M3Buffer[i];
      m_cnt++;
     }
   if(m_cnt lt 2 && s2 lt =M4Buffer[i] && M4Buffer[i] lt =r2)
     {
      if(m_cnt==0) Medium1Buffer[i]=M4Buffer[i]; else Medium2Buffer[i]=M4Buffer[i];
      m_cnt++;
     }
   if(m_cnt lt 2 && s2 lt =M5Buffer[i] && M5Buffer[i] lt =r2)
     {
      if(m_cnt==0) Medium1Buffer[i]=M5Buffer[i]; else Medium2Buffer[i]=M5Buffer[i];
      m_cnt++;
     }
   if(m_cnt lt 2 && s2 lt =M6Buffer[i] && M6Buffer[i] lt =r2)
     {
      if(m_cnt==0) Medium1Buffer[i]=M6Buffer[i]; else Medium2Buffer[i]=M6Buffer[i];
      m_cnt++;
     }
   if(m_cnt lt 2 && s2 lt =M7Buffer[i] && M7Buffer[i] lt =r2)
     {
      if(m_cnt==0) Medium1Buffer[i]=M7Buffer[i]; else Medium2Buffer[i]=M7Buffer[i];
      m_cnt++;
     }
   if(m_cnt lt 2 && s2 lt =M8Buffer[i] && M8Buffer[i] lt =r2)
     {
      if(m_cnt==0) Medium1Buffer[i]=M8Buffer[i]; else Medium2Buffer[i]=M8Buffer[i];
      m_cnt++;
     }
//---
   if(m_cnt lt 1)Medium1Buffer[i] = Medium1Buffer[i-1];
   if(m_cnt lt 2)Medium2Buffer[i] = Medium2Buffer[i-1];
  }
//+------------------------------------------------------------------+
//| set long term peak                                               |
//+------------------------------------------------------------------+
void set_lt_peeks(double s2,double r2,int i)
  {
//--- long term peak lines
   int l_cnt=0;
   if(s2 lt =L1Buffer[i] && L1Buffer[i] lt =r2)
     {
      Long1Buffer[i]=L1Buffer[i];
      l_cnt++;
     }
   else if(s2 lt =L2Buffer[i] && L2Buffer[i] lt =r2)
     {
      if(l_cnt==0) Long1Buffer[i]=L2Buffer[i]; else Long2Buffer[i]=L2Buffer[i];
      l_cnt++;
     }
   else if(l_cnt lt 2 && s2 lt =L3Buffer[i] && L3Buffer[i] lt =r2)
     {
      if(l_cnt==0) Long1Buffer[i]=L3Buffer[i]; else Long2Buffer[i]=L3Buffer[i];
      l_cnt++;
     }
   else if(l_cnt lt 2 && s2 lt =L4Buffer[i] && L4Buffer[i] lt =r2)
     {
      if(l_cnt==0) Long1Buffer[i]=L4Buffer[i]; else Long2Buffer[i]=L4Buffer[i];
      l_cnt++;
     }
   else if(l_cnt lt 2 && s2 lt =L5Buffer[i] && L5Buffer[i] lt =r2)
     {
      if(l_cnt==0) Long1Buffer[i]=L5Buffer[i]; else Long2Buffer[i]=L5Buffer[i];
      l_cnt++;
     }
   else if(l_cnt lt 2 && s2 lt =L6Buffer[i] && L6Buffer[i] lt =r2)
     {
      if(l_cnt==0) Long1Buffer[i]=L6Buffer[i]; else Long2Buffer[i]=L6Buffer[i];
      l_cnt++;
     }
   else if(l_cnt lt 2 && s2 lt =L7Buffer[i] && L7Buffer[i] lt =r2)
     {
      if(l_cnt==0) Long1Buffer[i]=L7Buffer[i]; else Long2Buffer[i]=L7Buffer[i];
      l_cnt++;
     }
   else if(l_cnt lt 2 && s2 lt =L8Buffer[i] && L8Buffer[i] lt =r2)
     {
      if(l_cnt==0) Long1Buffer[i]=L8Buffer[i]; else Long2Buffer[i]=L8Buffer[i];
      l_cnt++;
     }
//---
   if(l_cnt lt 1)Long1Buffer[i] = Long1Buffer[i-1];
   if(l_cnt lt 2)Long2Buffer[i] = Long2Buffer[i-1];
  }
//+------------------------------------------------------------------+
//| Short term peak line                                             |
//+------------------------------------------------------------------+
bool calc_ds_peaks(int &d1_peaks[],int &st_peaks[],datetime t)
  {
   double m5high[];
   double m5low[];
   long m5vol[];
   ArraySetAsSeries(m5high,true);
   ArraySetAsSeries(m5low,true);
   ArraySetAsSeries(m5vol,true);
   int m5_len1=CopyTickVolume(Symbol(),PERIOD_M5,t,st_period,m5vol);
   int m5_len2=CopyHigh(Symbol(),PERIOD_M5,t,st_period,m5high);
   int m5_len3=CopyLow (Symbol(),PERIOD_M5,t,st_period,m5low);
   if(st_period==m5_len1 && m5_len1==m5_len2 && m5_len2==m5_len3)
     {
      //--- Short term peak line
      int st_offset=(int)MathRound(m5low[ArrayMinimum(m5low)]/_Point);
      calc_histgram(st_peaks,m5high,m5low,m5vol,st_period,st_offset,InpBinRange);
      //--- 1Day peak line
      int d1_offset=(int)MathRound(m5low[ArrayMinimum(m5low,0,d1_period)]/_Point);
      calc_histgram(d1_peaks,m5high,m5low,m5vol,d1_period,d1_offset,InpBinRange,d1_period);
      return (true);
     }
   return (false);
  }
//+------------------------------------------------------------------+
//| Long term peak line                                              |
//+------------------------------------------------------------------+
bool calc_ml_peaks(int  <_peaks[],int  &mt_peaks[],datetime t)
  {
   double h1high[];
   double h1low[];
   long   h1vol[];
   ArraySetAsSeries(h1high,true);
   ArraySetAsSeries(h1low,true);
   ArraySetAsSeries(h1vol,true);

 

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.