Breakout Indicator For MT5

Breakout Indicator For MT5

Table Of Contents:

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

The Breakout Indicator For MT5 is an indicator that draws high and low levels on the chart which can be used to detect breakouts. You can define the begin and ending time of the zone from which the indicator calculates the high and low. The indicator then draws 2 solid and 2 dotted lines on the chart for each zone which matches the configured times. Because of the configuration parameters which contain hours and minutes this indicator is mainly used for intraday trading.

FREE Breakout Indicator

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

The Breakout Indicator For MT5 has 6 parameters to configure.

input uint     InpHourBegin   =  0;    // "Period" Hour begin input uint     InpMinBegin    =  0;    // "Period" Minutes begin input uint     InpHourEnd     =  5;    // "Period" Hour end input uint     InpMinEnd      =  0;    // "Period" Minutes end input uint     InpHourEndArea =  23;   // "Area" Hour end input uint     InpMinEndArea  =  0;    // "Area" Minutes end 

Buffers of the Breakout Indicator For MT5

The Breakout Indicator For MT5 provides 4 buffers.

SetIndexBuffer(0,BufferUpperPeriod,INDICATOR_DATA); SetIndexBuffer(1,BufferLowerPeriod,INDICATOR_DATA); SetIndexBuffer(2,BufferUpperArea,INDICATOR_DATA); SetIndexBuffer(3,BufferLowerArea,INDICATOR_DATA); 

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[])   { //--- @ gt 25@:0 =0  lt 8=8 lt 0;L= gt 5 : gt ;85AB2 gt  10@ gt 2 4;O @0AGQB0    if(rates_total lt 4) return 0; //--- #AB0= gt 2:0  lt 0AA82 gt 2 1CD5@ gt 2 :0: B09 lt A5@89    ArraySetAsSeries(high,true);    ArraySetAsSeries(low,true);    ArraySetAsSeries(time,true); //--- @ gt 25@:0 8 @0AGQB : gt ;8G5AB20 ?@ gt AG8BK205 lt KE 10@ gt 2    int limit=rates_total-prev_calculated;    if(limit gt 1)      {       limit=rates_total-1;       ArrayInitialize(BufferUpperPeriod,EMPTY_VALUE);       ArrayInitialize(BufferLowerPeriod,EMPTY_VALUE);       ArrayInitialize(BufferUpperArea,EMPTY_VALUE);       ArrayInitialize(BufferLowerArea,EMPTY_VALUE);      } //---  gt 43 gt B gt 2:0 40==KE    int begin_bar,end_bar;    double min_price,max_price; //---  0AGQB 8=48:0B gt @0    for(int i=limit; i gt =0 && !IsStopped(); i--)      {       int cur_min=TimeHour(time[i])*60+TimeMinute(time[i]);       if((period_end_min gt period_begin_min && cur_min gt =period_begin_min && cur_min lt =period_end_min) ||           (period_end_min lt period_begin_min && (cur_min gt =period_begin_min || cur_min lt =period_end_min)))         {          begin_bar=FindBar(InpHourBegin,InpMinBegin,time[i]);          if(begin_bar==WRONG_VALUE) continue;          int hb=Highest(begin_bar-i+1,i);          int lb=Lowest(begin_bar-i+1,i);          if(hb==WRONG_VALUE || lb==WRONG_VALUE) continue;          max_price=high[hb];          min_price=low[lb];          for(int j=begin_bar; j gt =i; j--)            {             BufferUpperPeriod[j]=max_price;             BufferLowerPeriod[j]=min_price;            }         }       else         {          BufferUpperPeriod[i]=EMPTY_VALUE;          BufferLowerPeriod[i]=EMPTY_VALUE;         }       if((box_end_mn gt period_end_min && cur_min gt =period_end_min && cur_min lt =box_end_mn) ||           (box_end_mn lt period_end_min && (cur_min gt =period_end_min || cur_min lt =box_end_mn)))         {          begin_bar=FindBar(InpHourBegin,InpMinBegin,time[i]);          end_bar=FindBar(InpHourEnd,InpMinEnd,time[i]);          if(begin_bar==WRONG_VALUE || end_bar==WRONG_VALUE) continue;          int hb=Highest(begin_bar-end_bar+1,end_bar);          int lb=Lowest(begin_bar-end_bar+1,end_bar);          if(hb==WRONG_VALUE || lb==WRONG_VALUE) continue;          max_price=high[hb];          min_price=low[lb];          for(int j=end_bar; j gt =i; j--)            {             BufferUpperArea[j]=max_price;             BufferLowerArea[j]=min_price;            }         }       else         {          BufferUpperArea[i]=EMPTY_VALUE;          BufferLowerArea[i]=EMPTY_VALUE;         }      }  //--- return value of prev_calculated for next call    return(rates_total);   } //+------------------------------------------------------------------+ //|  gt 72@0I05B G0A C:070== gt 3 gt  2@5 lt 5=8                                | //+------------------------------------------------------------------+ int TimeHour(const datetime time)   {    MqlDateTime tm;    TimeToStruct(time,tm);    return tm.hour;   } //+------------------------------------------------------------------+ //|  gt 72@0I05B  lt 8=CBC C:070== gt 3 gt  2@5 lt 5=8                             | //+------------------------------------------------------------------+ int TimeMinute(const datetime time)   {    MqlDateTime tm;    TimeToStruct(time,tm);    return tm.min;   } //+------------------------------------------------------------------+ //|                                                                  | //+------------------------------------------------------------------+ int FindBar(int hour,int minutes,datetime time)   {    MqlDateTime tm;    TimeToStruct(time,tm);    tm.hour=hour;    tm.min=minutes;    datetime t=StructToTime(tm);    if(t gt time)       t-=86400;    return BarShift(Symbol(),PERIOD_CURRENT,t);   } //+------------------------------------------------------------------+ //|  gt 72@0I05B A lt 5I5=85 10@0 ? gt  2@5 lt 5=8                              | //| https://www.mql5.com/ru/code/1864                                | //+------------------------------------------------------------------+ int BarShift(const string symbol_name,const ENUM_TIMEFRAMES timeframe,const datetime time,bool exact=false)   {    datetime last_bar;    if(!SeriesInfoInteger(symbol_name,timeframe,SERIES_LASTBAR_DATE,last_bar))      {       datetime array[1];       if(CopyTime(symbol_name,timeframe,0,1,array)==1)          last_bar=array[0];       else          return WRONG_VALUE;      }    if(time gt last_bar)       return(0);    int shift=Bars(symbol_name,timeframe,time,last_bar);    datetime array[1];    if(CopyTime(symbol_name,timeframe,time,1,array)==1)       return(array[0]==time ? shift-1 : exact && time gt array[0]+PeriodSeconds(timeframe) ? WRONG_VALUE : shift);    return WRONG_VALUE;   } //+------------------------------------------------------------------+ //|  gt 72@0I05B 8=45:A  lt 0:A8 lt 0;L= gt 3 gt  7=0G5=8O B09 lt A5@88 High          | //+------------------------------------------------------------------+ int Highest(const int count,const int start)   {    double array[];    ArraySetAsSeries(array,true);    if(CopyHigh(Symbol(),PERIOD_CURRENT,start,count,array)==count)       return ArrayMaximum(array)+start;    return WRONG_VALUE;   } //+------------------------------------------------------------------+ //|  gt 72@0I05B 8=45:A  lt 8=8 lt 0;L= gt 3 gt  7=0G5=8O B09 lt A5@88 Low            | //+------------------------------------------------------------------+ int Lowest(const int count,const int start)   {    double array[];    ArraySetAsSeries(array,true);    if(CopyLow(Symbol(),PERIOD_CURRENT,start,count,array)==count)       return ArrayMinimum(array)+start;    return WRONG_VALUE;   } //+------------------------------------------------------------------+ 

 

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.