Why This iFractal didn't work - page 2

 
Fernando Carreiro #:

Please pay attention to what is posted. I provided a link for the iFractals function, which includes an example for Fractals.

Did you read it? Did you experiment with the example code?

There are also examples in the CodeBase. Please do some research on their use.

Hold On Trying To Do Some Change With iFractal. 

Let Me Check. And Then I'll Share My Code Here, If You Can Help Me.

 
Fernando Carreiro #:

Please pay attention to what is posted. I provided a link for the iFractals function, which includes an example for Fractals.

Did you read it? Did you experiment with the example code?

There are also examples in the CodeBase. Please do some research on their use.

Nevermind, it didnt work for me sir.

I can't manage things together... because of my knowledge.

But I really appreciate what you do here for me.

Thanks

 

Here Is The Final Code, I Think It's Fine; But it cant draw the arrow on top of the higher time frame array :

IDK, Maybe There Is Buffer Or Array Problem.

Pleas Check This :


//+------------------------------------------------------------------+
//|                                                     Fractals.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
#property indicator_type1   DRAW_ARROW
#property indicator_type2   DRAW_ARROW
#property indicator_color1  Gray
#property indicator_color2  Gray
#property indicator_label1  "Fractal Up"
#property indicator_label2  "Fractal Down"
//---- indicator buffers
double ExtUpperBuffer[];
double ExtLowerBuffer[];
input ENUM_TIMEFRAMES Timeframe = PERIOD_M15;
double highValues[];
double lowValues[];

//--- 10 pixels upper from high price
int    ExtArrowShift=-10;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtUpperBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtLowerBuffer,INDICATOR_DATA);
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//---- sets first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_ARROW,217);
   PlotIndexSetInteger(1,PLOT_ARROW,218);
//---- arrow shifts when drawing
   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,ExtArrowShift);
   PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,-ExtArrowShift);
//---- sets drawing line empty value--
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0);
//---- initialization done
  }
//+------------------------------------------------------------------+
//|  Accelerator/Decelerator Oscillator                              |
//+------------------------------------------------------------------+
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 &TickVolume[],
                const long &Volume[],
                const int &Spread[])
  {
   int i,limit;
//---


   if(rates_total<5)
      return(0);
//---
   if(prev_calculated<7)
     {
      limit=2;
      //--- clean up arrays
      ArrayInitialize(ExtUpperBuffer,0.0);
      ArrayInitialize(ExtLowerBuffer,0.0);
     }
   else limit=rates_total-5;
   
    ArraySetAsSeries(highValues, true);
    ArraySetAsSeries(lowValues, true);


for (int i = limit; i < rates_total-3; i++)
{
    highValues[i] = iHigh(Symbol(), Timeframe, i);
    lowValues[i] = iLow(Symbol(), Timeframe, i);
}

   for(i=limit;i<rates_total-3;i++)
     {

      //---- Upper Fractal
      if(highValues[i]>highValues[i+1] && highValues[i]>highValues[i+2] && highValues[i]>=highValues[i-1] && highValues[i]>=highValues[i-2])
         ExtUpperBuffer[i]=highValues[i];
      else ExtUpperBuffer[i]=0.0;

      //---- Lower Fractal
      if(lowValues[i]<lowValues[i+1] && lowValues[i]<lowValues[i+2] && lowValues[i]<=lowValues[i-1] && lowValues[i]<=lowValues[i-2])
         ExtLowerBuffer[i]=lowValues[i];
      else ExtLowerBuffer[i]=0.0;
     }
//--- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }

//+------------------------------------------------------------------+
 

Good morning
there are warnings for me in the ifractal example code
Nothing serious

//#property indicator_chart_window
//#property indicator_buffers 1
//#property indicator_plots   1
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2

But for me the timeframe selection does not work

 
Gerard Willia G J B M Dinh Sy #:

Good morning
there are warnings for me in the ifractal example code
Nothing serious

But for me the timeframe selection does not work

Yeah I Remove that first buffer property.

but, it's not working...

 
p4rnak #:

Yeah I Remove that first buffer property.

but, it's not working...

a possible example to use MTF Fractals in right way. 

//+------------------------------------------------------------------+
//|                                               Demo_iFractals.mq5 |
//|                        Copyright 2011, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property description "The indicator demonstrates how to obtain data"
#property description "of indicator buffers for the iFractals technical indicator."
#property description "A symbol and timeframe used for calculation of the indicator,"
#property description "are set by the symbol and period parameters."
#property description "The method of creation of the handle is set through the 'type' parameter (function type)."

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   4
//--- the FractalUp plot
#property indicator_label1  "FractalUp"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrBlue
//--- the FractalDown plot
#property indicator_label2  "FractalDown"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrRed
//--- the FractalUp plot
#property indicator_label3  "FractalUp2"
#property indicator_type3   DRAW_ARROW
#property indicator_color3  clrBlue
//--- the FractalDown plot
#property indicator_label4  "FractalDown2"
#property indicator_type4   DRAW_ARROW
#property indicator_color4  clrRed
//+------------------------------------------------------------------+
//| Enumeration of the methods of handle creation                    |
//+------------------------------------------------------------------+

input string               symbol=" ";                   // symbol
input ENUM_TIMEFRAMES      period=PERIOD_M1;        // timeframe
input ENUM_TIMEFRAMES      period2=PERIOD_M5;        // timeframe
//--- indicator buffers
double         FractalUpBuffer[],FractalUpBuffer2[];
double         FractalDownBuffer[],FractalDownBuffer2[];
//--- variable for storing the handle of the iFractals indicator
int    handle,handle2;
//--- variable for storing
string name=symbol;
//--- name of the indicator on a chart
string short_name,short_name2;
//--- we will keep the number of values in the Fractals indicator
int    bars_calculated=0,bars_calculated2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit() {
//--- assignment of arrays to indicator buffers
   SetIndexBuffer(0,FractalUpBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,FractalDownBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,FractalUpBuffer2,INDICATOR_DATA);
   SetIndexBuffer(3,FractalDownBuffer2,INDICATOR_DATA);
//--- set codes using a symbol from the Wingdings charset for the PLOT_ARROW property
   PlotIndexSetInteger(0,PLOT_ARROW,217); // arrow up
   PlotIndexSetInteger(1,PLOT_ARROW,218); // arrow down
   PlotIndexSetInteger(2,PLOT_ARROW,217); // arrow up
   PlotIndexSetInteger(3,PLOT_ARROW,218); // arrow down
//--- determine the symbol the indicator is drawn for
   name=symbol;
//--- delete spaces to the right and to the left
   StringTrimRight(name);
   StringTrimLeft(name);
//--- if it results in zero length of the 'name' string
   if(StringLen(name)==0) {
      //--- take the symbol of the chart the indicator is attached to
      name=_Symbol;
   }
//--- create handle of the indicator

   handle=iFractals(name,period);
   handle2=iFractals(name,period2);

//--- if the handle is not created
   if(handle==INVALID_HANDLE) {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iFractals indicator for the symbol %s/%s, error code %d",
                  name,
                  EnumToString(period),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
   }
   if(handle2==INVALID_HANDLE) {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iFractals2 indicator for the symbol %s/%s, error code %d",
                  name,
                  EnumToString(period2),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
   }
//--- show the symbol/timeframe the Fractals indicator is calculated for
   short_name=StringFormat("iFractals(%s/%s)",name,EnumToString(period));
   short_name2=StringFormat("iFractals(%s/%s)",name,EnumToString(period2));
   IndicatorSetString(INDICATOR_SHORTNAME,short_name);
//--- normal initialization of the indicator
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[]) {
//--- number of values copied from the iFractals indicator
   int values_to_copy, values_to_copy2;
//--- determine the number of values calculated in the indicator
   int calculated=BarsCalculated(handle);
   int calculated2=BarsCalculated(handle2);
   if(calculated<=0) {
      PrintFormat("BarsCalculated() returned %d, error code %d",calculated,GetLastError());
      return(0);
   }
   if(calculated2<=0) {
      PrintFormat("BarsCalculated2() returned %d, error code %d",calculated2,GetLastError());
      return(0);
   }
//--- if it is the first start of calculation of the indicator or if the number of values in the iFractals indicator changed
//---or if it is necessary to calculated the indicator for two or more bars (it means something has changed in the price history)
   if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1) {
      //--- if the FractalUpBuffer array is greater than the number of values in the iFractals indicator for symbol/period, then we don't copy everything
      //--- otherwise, we copy less than the size of indicator buffers
      if(calculated>rates_total) values_to_copy=rates_total;
      else                       values_to_copy=calculated;
   } else {
      //--- it means that it's not the first time of the indicator calculation, and since the last call of OnCalculate()
      //--- for calculation not more than one bar is added
      values_to_copy=(rates_total-prev_calculated)+1;
   }

   if(prev_calculated==0 || calculated2!=bars_calculated2 || rates_total>prev_calculated+1) {
      //--- if the FractalUpBuffer array is greater than the number of values in the iFractals indicator for symbol/period, then we don't copy everything
      //--- otherwise, we copy less than the size of indicator buffers
      if(calculated2>rates_total) values_to_copy2=rates_total;
      else                       values_to_copy2=calculated2;
   } else {
      //--- it means that it's not the first time of the indicator calculation, and since the last call of OnCalculate()
      //--- for calculation not more than one bar is added
      values_to_copy2=(rates_total-prev_calculated)+1;
   }
//--- fill the FractalUpBuffer and FractalDownBuffer arrays with values from the Fractals indicator
//--- if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
   if(!FillArraysFromBuffers(FractalUpBuffer,FractalDownBuffer,handle,values_to_copy)) return(0);
   if(!FillArraysFromBuffers(FractalUpBuffer2,FractalDownBuffer2,handle2,values_to_copy)) return(0);
//--- form the message
   string comm=StringFormat("%s ==>  Updated value in the indicator %s: %d",
                            TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),
                            short_name,
                            values_to_copy);

   string comm2=StringFormat("%s ==>  Updated value in the indicator %s: %d",
                            TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),
                            short_name2,
                            values_to_copy2);
//--- display the service message on the chart
   Comment(comm,"\n",comm2);
//--- memorize the number of values in the Fractals indicator
   bars_calculated=calculated;
   bars_calculated2=calculated2;
//--- return the prev_calculated value for the next call
   return(rates_total);
}
//+------------------------------------------------------------------+
//| Filling indicator buffers from the iFractals indicator           |
//+------------------------------------------------------------------+
bool FillArraysFromBuffers(double &up_arrows[],        // indicator buffer for up arrows
                           double &down_arrows[],      // indicator buffer for down arrows
                           int ind_handle,             // handle of the iFractals indicator
                           int amount                  // number of copied values
                          ) {
//--- reset error code
   ResetLastError();
//--- fill a part of the FractalUpBuffer array with values from the indicator buffer that has 0 index
   if(CopyBuffer(ind_handle,0,0,amount,up_arrows)<0) {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the iFractals indicator to the FractalUpBuffer array, error code %d",
                  GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
   }
//--- fill a part of the FractalDownBuffer array with values from the indicator buffer that has index 1
   if(CopyBuffer(ind_handle,1,0,amount,down_arrows)<0) {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the iFractals indicator to the FractalDownBuffer array, error code %d",
                  GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
   }
//--- everything is fine
   return(true);
}
//+------------------------------------------------------------------+
//| Indicator deinitialization function                              |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
   if(handle!=INVALID_HANDLE)
      IndicatorRelease(handle);
      if(handle2!=INVALID_HANDLE)
      IndicatorRelease(handle2);
//--- clear the chart after deleting the indicator
   Comment("");
}
//+------------------------------------------------------------------+
 
Arpit T #:

a possible example to use MTF Fractals in right way. 

thans a lot.

but this have not a normal result :


 

Yes its just an idea so you know what you were doing wrong. It shows you how to use Handle

To shift arrows

 PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,10);

You need to study this and play with value 10

 
Arpit T #:

Yes its just an idea so you know what you were doing wrong. It shows you how to use Handle

To shift arrows

You need to study this and play with value 10

yeah, I try that; but it's not about shift arrow :

//+------------------------------------------------------------------+
//|                                               Demo_iFractals.mq5 |
//|                        Copyright 2011, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property description "The indicator demonstrates how to obtain data"
#property description "of indicator buffers for the iFractals technical indicator."
#property description "A symbol and timeframe used for calculation of the indicator,"
#property description "are set by the symbol and period parameters."
#property description "The method of creation of the handle is set through the 'type' parameter (function type)."

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   4
//--- the FractalUp plot
#property indicator_label1  "FractalUp"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrBlue
//--- the FractalDown plot
#property indicator_label2  "FractalDown"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrRed
//--- the FractalUp plot
#property indicator_label3  "FractalUp2"
#property indicator_type3   DRAW_ARROW
#property indicator_color3  clrBlue
//--- the FractalDown plot
#property indicator_label4  "FractalDown2"
#property indicator_type4   DRAW_ARROW
#property indicator_color4  clrRed
//+------------------------------------------------------------------+
//| Enumeration of the methods of handle creation                    |
//+------------------------------------------------------------------+

input string               symbol=" ";                   // symbol
input ENUM_TIMEFRAMES      period=PERIOD_M1;        // timeframe
input ENUM_TIMEFRAMES      period2=PERIOD_M5;        // timeframe
//--- indicator buffers
double         FractalUpBuffer[],FractalUpBuffer2[];
double         FractalDownBuffer[],FractalDownBuffer2[];
//--- variable for storing the handle of the iFractals indicator
int    handle,handle2;
//--- variable for storing
string name=symbol;
//--- name of the indicator on a chart
string short_name,short_name2;
//--- we will keep the number of values in the Fractals indicator
int    bars_calculated=0,bars_calculated2=0;
int ExtArrowShift=10;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit() {
//--- assignment of arrays to indicator buffers
   SetIndexBuffer(0,FractalUpBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,FractalDownBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,FractalUpBuffer2,INDICATOR_DATA);
   SetIndexBuffer(3,FractalDownBuffer2,INDICATOR_DATA);
//--- set codes using a symbol from the Wingdings charset for the PLOT_ARROW property
   PlotIndexSetInteger(0,PLOT_ARROW,217); // arrow up
   PlotIndexSetInteger(1,PLOT_ARROW,218); // arrow down
   PlotIndexSetInteger(2,PLOT_ARROW,217); // arrow up
   PlotIndexSetInteger(3,PLOT_ARROW,218); // arrow down
   
   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-ExtArrowShift);
   PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,ExtArrowShift);
   PlotIndexSetInteger(2,PLOT_ARROW_SHIFT,-ExtArrowShift);
   PlotIndexSetInteger(3,PLOT_ARROW_SHIFT,ExtArrowShift);
//--- determine the symbol the indicator is drawn for
   name=symbol;
//--- delete spaces to the right and to the left
   StringTrimRight(name);
   StringTrimLeft(name);
//--- if it results in zero length of the 'name' string
   if(StringLen(name)==0) {
      //--- take the symbol of the chart the indicator is attached to
      name=_Symbol;
   }
//--- create handle of the indicator

   handle=iFractals(name,period);
   handle2=iFractals(name,period2);

//--- if the handle is not created
   if(handle==INVALID_HANDLE) {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iFractals indicator for the symbol %s/%s, error code %d",
                  name,
                  EnumToString(period),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
   }
   if(handle2==INVALID_HANDLE) {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iFractals2 indicator for the symbol %s/%s, error code %d",
                  name,
                  EnumToString(period2),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
   }
//--- show the symbol/timeframe the Fractals indicator is calculated for
   short_name=StringFormat("iFractals(%s/%s)",name,EnumToString(period));
   short_name2=StringFormat("iFractals(%s/%s)",name,EnumToString(period2));
   IndicatorSetString(INDICATOR_SHORTNAME,short_name);
//--- normal initialization of the indicator
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[]) {
//--- number of values copied from the iFractals indicator
   int values_to_copy, values_to_copy2;
//--- determine the number of values calculated in the indicator
   int calculated=BarsCalculated(handle);
   int calculated2=BarsCalculated(handle2);
   if(calculated<=0) {
      PrintFormat("BarsCalculated() returned %d, error code %d",calculated,GetLastError());
      return(0);
   }
   if(calculated2<=0) {
      PrintFormat("BarsCalculated2() returned %d, error code %d",calculated2,GetLastError());
      return(0);
   }
//--- if it is the first start of calculation of the indicator or if the number of values in the iFractals indicator changed
//---or if it is necessary to calculated the indicator for two or more bars (it means something has changed in the price history)
   if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1) {
      //--- if the FractalUpBuffer array is greater than the number of values in the iFractals indicator for symbol/period, then we don't copy everything
      //--- otherwise, we copy less than the size of indicator buffers
      if(calculated>rates_total) values_to_copy=rates_total;
      else                       values_to_copy=calculated;
   } else {
      //--- it means that it's not the first time of the indicator calculation, and since the last call of OnCalculate()
      //--- for calculation not more than one bar is added
      values_to_copy=(rates_total-prev_calculated)+1;
   }

   if(prev_calculated==0 || calculated2!=bars_calculated2 || rates_total>prev_calculated+1) {
      //--- if the FractalUpBuffer array is greater than the number of values in the iFractals indicator for symbol/period, then we don't copy everything
      //--- otherwise, we copy less than the size of indicator buffers
      if(calculated2>rates_total) values_to_copy2=rates_total;
      else                       values_to_copy2=calculated2;
   } else {
      //--- it means that it's not the first time of the indicator calculation, and since the last call of OnCalculate()
      //--- for calculation not more than one bar is added
      values_to_copy2=(rates_total-prev_calculated)+1;
   }
//--- fill the FractalUpBuffer and FractalDownBuffer arrays with values from the Fractals indicator
//--- if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
   if(!FillArraysFromBuffers(FractalUpBuffer,FractalDownBuffer,handle,values_to_copy)) return(0);
   if(!FillArraysFromBuffers(FractalUpBuffer2,FractalDownBuffer2,handle2,values_to_copy)) return(0);
//--- form the message
   string comm=StringFormat("%s ==>  Updated value in the indicator %s: %d",
                            TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),
                            short_name,
                            values_to_copy);

   string comm2=StringFormat("%s ==>  Updated value in the indicator %s: %d",
                            TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),
                            short_name2,
                            values_to_copy2);
//--- display the service message on the chart
   Comment(comm,"\n",comm2);
//--- memorize the number of values in the Fractals indicator
   bars_calculated=calculated;
   bars_calculated2=calculated2;
//--- return the prev_calculated value for the next call
   return(rates_total);
}
//+------------------------------------------------------------------+
//| Filling indicator buffers from the iFractals indicator           |
//+------------------------------------------------------------------+
bool FillArraysFromBuffers(double &up_arrows[],        // indicator buffer for up arrows
                           double &down_arrows[],      // indicator buffer for down arrows
                           int ind_handle,             // handle of the iFractals indicator
                           int amount                  // number of copied values
                          ) {
//--- reset error code
   ResetLastError();
//--- fill a part of the FractalUpBuffer array with values from the indicator buffer that has 0 index
   if(CopyBuffer(ind_handle,0,0,amount,up_arrows)<0) {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the iFractals indicator to the FractalUpBuffer array, error code %d",
                  GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
   }
//--- fill a part of the FractalDownBuffer array with values from the indicator buffer that has index 1
   if(CopyBuffer(ind_handle,1,0,amount,down_arrows)<0) {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the iFractals indicator to the FractalDownBuffer array, error code %d",
                  GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
   }
//--- everything is fine
   return(true);
}
//+------------------------------------------------------------------+
//| Indicator deinitialization function                              |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
   if(handle!=INVALID_HANDLE)
      IndicatorRelease(handle);
      if(handle2!=INVALID_HANDLE)
      IndicatorRelease(handle2);
//--- clear the chart after deleting the indicator
   Comment("");
}
//+------------------------------------------------------------------+



 
p4rnak:
        UpFractalBuffer[i] = iFractals(NULL, TimeFrame1, i);

You are mixing apples and oranges.