Discussion of article "The power of ZigZag (part I). Developing the base class of the indicator" - page 8

 
 

The third and fourth still don't compile.

 

'GetZigZagData' - none of the overloads can be applied to the function call TestZZZ_03.mq5 77 15

"Get ZigZag Data" - none of the overloads can be applied to the function call test z_03.mq5 77 15

---------------------

could be one of 2 function(s) TestZZZ_03.mq5 77 15

could be one of 2 function(s) TestZZ_03.at MQL5 77 15

---------------------

void CZigZagModule::GetZigZagData(const int,int,int,const string,const ENUM_TIMEFRAMES,const datetime,const datetime) ZigZagModule.mqh 52 22

void CZigZagModule::GetZigZagData(const double&[],const double&[],const datetime&[]) ZigZagModule.mqh 51 22

______________

That is, the compiler swears that one and the same function is initiated with different parameters.

 
Sergey Voytsekhovsky:

The third and fourth still do not compile.

Check the transmitted parameters. Either their number or types are incorrect. This is when calling GetZigZagData.

 
ZY: Why do you program in C if you are not sure that you can address a function with different parameters?
 

Thanks for the feedback. I don't know how to check the parameters yet, I'm just learning programming. From what I have managed to understand - in the code the Expert Advisor calls the GetZigZagData() method.

The first time with parameters GetZigZagData(h_zz,l_zz,t_zz),

the second time with different parameters GetZigZagData(zz_handle_current,_Symbol,_Period,start_time_in,stop_time_in).

The inclusion file has both options

void CZigZagModule::GetZigZagData(const double &zz_h[],const double &zz_l[],const datetime &time[])
  {
   int h_total =::ArraySize(zz_h);
   int l_total =::ArraySize(zz_l);
   int total   =h_total+l_total;
//--- Zeroing of ZZ variables
   ZeroZigZagData();
//--- Let's loop through the copied ZZ values
   for(int i=0; i<total; i++)
     {
      //--- If we have already got the required number of maxima and minima of ZZ, exit the loop
      if(m_counter_highs==m_copy_extremums && m_counter_lows==m_copy_extremums)
         break;
      //--- Array overrun control
      if(i>=h_total || i>=l_total)
         break;
      //--- Fill the maxima array until we have copied the required number of maxima
      if(zz_h[i]>0 && m_counter_highs<m_copy_extremums)
        {
         m_zz_high[m_counter_highs]      =zz_h[i];
         m_zz_high_bar[m_counter_highs]  =i;
         m_zz_high_time[m_counter_highs] =time[i];
         //--- Increase the maxima counter
         m_counter_highs++;
        }
      //--- Fill the array of minima until the required number is copied
      if(zz_l[i]>0 && m_counter_lows<m_copy_extremums)
        {
         m_zz_low[m_counter_lows]      =zz_l[i];
         m_zz_low_bar[m_counter_lows]  =i;
         m_zz_low_time[m_counter_lows] =time[i];
         //--- Increase the minimum count.
         m_counter_lows++;
        }
     }
//--- Determine the direction of price movement
   m_direction=(m_zz_high_time[0]>m_zz_low_time[0])? 1 : -1;
  }
//+------------------------------------------------------------------+
//|| Gets ZZ data from the passed handle |
//+------------------------------------------------------------------+
void CZigZagModule::GetZigZagData(const int handle,int buffer_num_highs,int buffer_num_lows,
                                  const string symbol,const ENUM_TIMEFRAMES period,
                                  const datetime start_time,const datetime stop_time)
  {
//--- Let's get the initial data
   int times_total =::CopyTime(symbol,period,start_time,stop_time,m_zz_time_temp);
   int highs_total =::CopyBuffer(handle,buffer_num_highs,start_time,stop_time,m_zz_highs_temp);
   int lows_total  =::CopyBuffer(handle,buffer_num_lows,start_time,stop_time,m_zz_lows_temp);
//--- Maximum number of extrema
   int max_items =(int)::fmax((double)highs_total,(double)lows_total);
//--- If it's not enough, let's try again.
   if(times_total<max_items)
     {
      while(true)
        {
         ::Sleep(100);
         times_total=::CopyTime(symbol,period,start_time,stop_time,m_zz_time_temp);
         if(times_total>=max_items)
            break;
        }
     }
//--- Counters
   int lows_counter  =0;
   int highs_counter =0;
//--- Calculate the maxima
   int h_total=::ArraySize(m_zz_highs_temp);
   for(int i=0; i<h_total; i++)
     {
      if(m_zz_highs_temp[i]>0)
         highs_counter++;
     }
//--- Calculate the minima
   int l_total=::ArraySize(m_zz_lows_temp);
   for(int i=0; i<l_total; i++)
     {
      if(m_zz_lows_temp[i]>0)
         lows_counter++;
     }
//--- Get the number of extrema
   int copy_extremums=(int)::fmin((double)highs_counter,(double)lows_counter);
   CopyExtremums(copy_extremums);
//--- Let's loop through the copied ZZ values
   GetZigZagData(m_zz_highs_temp,m_zz_lows_temp,m_zz_time_temp);
  }

written one after the other.

I loaded old archives, then new ones, deleted MT5 altogether, installed a new one from scratch, nothing helps, the error from the screen above persists.

 
Алексей Тарабанов:
ZY: Why do you program in C if you are not sure that you can address a function with different parameters?

I don't quite understand you. I have a lot of choices on what to program on? I have MT5, it is in MQL5, and I am trying to learn it.

I think that a function can be accessed with different parameters, I even read that it is called overloading. But I don't understand how to handle it. Moreover, I'm sure that it's not the author's mistake here at all, it's most likely that I'm making a mistake, the only question is where exactly ????.

 
   CopyExtremums(copy_extremums);
//--- Let's loop through the copied ZZ values
   GetZigZagData(m_zz_highs_temp,m_zz_lows_temp,m_zz_time_temp);
I think it's here.
 
Can someone please explain to a person what overloading is? I don't program in C.
 

I changed the names of these functions in the inclusion file. I added numbers 1 and 2 to them respectively.

I found all references to them in the Expert Advisor and edited them. The old error disappeared, but a new one appeared. Indeed - some problem with data types. The translator wrote as follows:

'stop_time_in' - unable to convert enumeration TestZZ_03.mq5 77 78