CopyBuffer and CopyTime Problem

Hello Members,

I have following problem with CopyTime & CopyBuffer with mql5


when I am printing data for iTime[0] its showing 0:00 1970 date means no value.

Also with fractal

    handle_fractal = iFractals(_Symbol, PERIOD_CURRENT);
      ArraySetAsSeries (fractal_down, true);
                //--- get the data
                CopyBuffer(handle_fractal,LOWER_LINE, 1, 1, fractal_down); 

when printing


it shows a long string of numbers.

Where I am mistaking, could you please help?

Thank you in advance.


1 Like

Please show the code that can be played. How do we know what is in your variables? How do we know which type of your variables are?

Example of the code being reproduced:

//|                                                      Test_en.mq5 |
//|                                      Copyright 2012, CompanyName |
//|                              |
#property script_show_inputs
input int            count=1;                // data count to copy 
//|                                                                  |
void OnStart()
   string            symbol_name=Symbol();   // symbol name 
   ENUM_TIMEFRAMES   timeframe=Period();     // period 
   int               start_pos=0;            // start position 
   datetime          time_array[];           // target array to copy open times 

   int result=CopyTime(symbol_name,timeframe,start_pos,count,time_array);
      Print("CopyTime error# ",GetLastError());
      Print("Ordered ",IntegerToString(count),", received ",IntegerToString(result));

if input parameter “data count to copy”==9, Result from the “Experts” tab:

[0] 2017.05.04 08:05:00 2017.05.04 08:06:00 2017.05.04 08:07:00 2017.05.04 08:08:00 2017.05.04 08:09:00
[5] 2017.05.04 08:10:00 2017.05.04 08:11:00 2017.05.04 08:12:00 2017.05.04 08:13:100:

Hello Vladimir, Pardon I solve the copytime problem, I was allocating it inside a loop thats why it was not working.

But Copybuffer with fractal indicator is still showing a long string. Here is the details with variable allocation & its type:

int handle_fractal,FractalBar = 5;
double fractal_up[],fractal_down[];

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[])

handle_fractal = iFractals(_Symbol, PERIOD_CURRENT);
ArraySetAsSeries (fractal_down, true);
ArraySetAsSeries (fractal_up, true);

 for(int f = 0; f<=FractalBar; f++)
               //--- get the data
                CopyBuffer(handle_fractal, LOWER_LINE, f, 1, fractal_down);               
               if(fractal_down[f]!= 0) // Current chart Dwn
               Do something          

//--- return value of prev_calculated for next call

Even if I don’t use the loop, use the plain code as following:

      //--- get the data
                CopyBuffer(handle_fractal,LOWER_LINE, 1, 1, fractal_down);      
it still prints a long string of data:

2017.05.04 14:46:38.647 Indicator MT5 (GBPUSD,M4)       179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00000000

Still not clear. I need price just like it shows up in mql4 with ifractal function. In mql4 for Fractal up it shows double value and if there is no fractal up its shows 0

Where I should use the EMPTY_VALUE on my code structure.

Thank you in advance


Perhaps you should read the manual. PrintFormat takes a format string and one or more values. You meant Print
There will never be a fractal on the current bar (or bar one.) Try 2.


Thank you for the suggestion. I tried it with Print & PrintFormat both. Didn’t created any difference with 0 index, long string number.

Plus with fractal_down[2] as you suggested, it shows array out of range error in both cases.

Check already in the help what is the value of EMPTY_VALUE.

IFractal indicator in the indicator buffer can store:

or price (in this case, you see the arrow)
or a value EMPTY_VALUE
So in the indicator buffer iFractal can be either a price or a EMPTY_VALUE.

1 Like