UtterFractals Indicator For MT5
The UtterFractals Indicator For MT5 can be a useful tool for traders who analyze market wave structure. The idea for this indicator was first presented by Mikhail Ptero. Upper indicator extremums are computed by the bar highs, while lower extremums are calculated by the bar lows.
The logic behind extremums calculation is determined by the ExistUp and ExistDn functions in the indicator code. Relevancy of the extremum detected is dependent on the process of extremums calculation. Insignificant extremums do not get displayed. Users can employ the UtterFractals indicator to construct trading systems that are based solely on market structure.
Installing the UtterFractals 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 utterfractals.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 UtterFractals Indicator For MT5
The UtterFractals Indicator For MT5 has 3 parameters to configure.
input uint QuantityOfBars_=1000; // History observation depth in bars
input int UpLable=217; // Upper fractal symbol code
input int DnLable=218; // Lower fractal symbol code
Buffers of the UtterFractals Indicator For MT5
The UtterFractals Indicator For MT5 provides 2 buffers.
SetIndexBuffer(0,Up,INDICATOR_DATA);
SetIndexBuffer(1,Dn,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[])
{
//---- checking the number of bars to be enough for the calculation
if(rates_total lt StartBars) return(0);
//---- indexing elements in arrays as time series
ArraySetAsSeries(high,true);
ArraySetAsSeries(low,true);
ArraySetAsSeries(open,true);
ArraySetAsSeries(close,true);
bool actual_back,actual_forward;
int i,j,TypeDuo;
Up[0]=0;
Up[1]=0;
Dn[0]=0;
Dn[1]=0;
if(int(QuantityOfBars) gt rates_total-21) QuantityOfBars=rates_total-21;
for(i=int(QuantityOfBars); i gt 1; i--) // basic iteration
{
Up[i]=0;
Dn[i]=0;
//--- the upper extremum is found, the lower one is absent
//--- in case the upper extremum is found
if(ExistUp(i,high) && !ExistDn(i,high))
{
//--- zeroing out the relevance flag when viewed back in history
actual_back=false;
//--- storing the bar, at which the upper extremum is found
j=i;
//--- preparing to move back to the past in history along the bars according to the review value
while(j lt i+review)
{
//--- enlarging the move counter back in history
j++;
//--- if there is an upper extremum and it is above or equal to the current one, then our upper one is irrelevant
if(ExistUp(j,high) && !ExistDn(j,high) && high[j] gt =high[i]) {actual_back=false; break;}
//--- if there is a lower extremum and it is below the current one, then our upper one is relevant
if(ExistDn(j,high) && !ExistUp(j,high) && low[j] lt high[i]) {actual_back=true; break;}
//--- if both lower and upper extremums are found
if(ExistDn(j,high) && ExistUp(j,high))
{
TypeDuo=IdentDualExtr(j,open,low,high,close);
switch(TypeDuo)
{
case 1:
actual_back=true;
break;
case 2:
actual_back=true;
break;
case 3:
actual_back=true;
break;
case 4:
actual_back=true;
break;
case 5:
actual_back=true;
break;
case 6:
actual_back=true;
break;
case 7:
actual_back=true;
break;
case 8:
actual_back=true;
break;
case 9:
actual_back=true;
break;
case 10:
actual_back=true;
break;
case 11:
actual_back=true;
break;
case 12:
actual_back=true;
break;
case 13:
actual_back=true;
break;
case 14:
actual_back=true;
break;
case 15:
actual_back=true;
break;
case 16:
actual_back=true;
break;
case 17:
actual_back=true;
break;
case 18:
actual_back=true;
break;
case 19:
actual_back=true;
break;
case 20:
actual_back=true;
break;
case 21:
actual_back=true;
break;
case 22:
actual_back=true;
break;
case 23:
actual_back=false;
break;
case 24:
actual_back=false;
break;
case 25:
actual_back=true;
break;
case 26:
actual_back=true;
break;
case 27:
actual_back=true;
break;
case 28:
actual_back=true;
break;
case 29:
actual_back=true;
break;
case 30:
actual_back=true;
break;
case 31:
actual_back=true;
break;
case 32:
actual_back=true;
break;
}
break;
}
}
//--- zeroing out the relevance flag when viewed forward in history
actual_forward=false;
//--- storing the bar, at which the upper extremum is found
j=i;
//--- preparing to move forward in history along the bars according to the review value
while(j gt i-review)
{
if(j lt 2) break;
//--- enlarging the move counter forward in history
j--;
//--- if there is an upper extremum and it is above the current one, then our upper one is irrelevant
if(ExistUp(j,high) && !ExistDn(j,high) && high[j] gt high[i]) {actual_forward=false; break;}
//--- if there is a lower extremum and it is below the current one, then our upper one is relevant
if(ExistDn(j,high) && !ExistUp(j,high) && low[j] lt high[i]) {actual_forward=true; break;}
//--- if both lower and upper extremums are found
if(ExistDn(j,high) && ExistUp(j,high))
{
TypeDuo=IdentDualExtr(j,open,low,high,close);
switch(TypeDuo)
{
case 1:
actual_forward=true;
break;
case 2:
actual_forward=false;
break;
case 3:
actual_forward=false;
break;
case 4:
actual_forward=true;
break;
case 5:
actual_forward=true;
break;
case 6:
actual_forward=true;
break;
case 7:
actual_forward=true;
break;
case 8:
actual_forward=true;
break;
case 9:
actual_forward=true;
break;
case 10:
actual_forward=true;
break;
case 11:
actual_forward=true;
break;
case 12:
actual_forward=true;
break;
case 13:
actual_forward=true;
break;
case 14:
actual_forward=true;
break;
case 15:
actual_forward=true;
break;
case 16:
actual_forward=true;
break;
case 17:
actual_forward=true;
break;
case 18:
actual_forward=true;
break;
case 19:
actual_forward=true;
break;
case 20:
actual_forward=true;
break;
case 21:
actual_forward=true;
break;
case 22:
actual_forward=true;
break;
case 23:
actual_forward=true;
break;
case 24:
actual_forward=true;
break;
case 25:
actual_forward=true;
break;
case 26:
actual_forward=true;
break;
case 27:
actual_forward=false;
break;
case 28:
actual_forward=false;
break;
case 29:
actual_forward=true;
break;
case 30:
actual_forward=true;
break;
case 31:
actual_forward=true;
break;
case 32:
actual_forward=true;
}
break;
}
}
//--- in case everything is OK behind and ahead
if(actual_back && actual_forward)
{
//--- filling the Up array using Up_tmp variable
Up_tmp=high[i];
}
//--- in case the extremum is irrelevant, the array must be zeroed out using Up_tmp variable
else Up_tmp=0;
}
//--- everything is executed, in case the upper extremum is found
//--- in case the upper extremum is absent, the array must be zeroed out using Up_tmp variable
else Up_tmp=0;