help me....error ambiguous call to overloaded function with the same parameters

 

what is this compiling error?

help me

//+------------------------------------------------------------------+
//|                                                   CF_XML_Lib.mq4 |
//|                                                 Eugenio Bravetti |
//|                                   http://www.eugeniobravetti.com |
//+------------------------------------------------------------------+
#property copyright "Eugenio Bravetti"
#property link      "http://www.eugeniobravetti.com"
#property library

#include <All_include.mqh>

//+------------------------------------------------------------------+
//| getFilteredRSS function
//+------------------------------------------------------------------+
int getFilteredRSS( string &arrayDest[][], string &arraySource[][], int impact, string currency = "", int date = 0 )
{
   int i;
   int index;

   // arraySource description
   // 0 = title
   // 1 = country
   // 2 = datetime
   // 3 = impact
   // 4 = forecast
   // 5 = previous

   ArrayResize( arrayDest, 0 );

   for ( i = 0; i < ArrayRange(arraySource, 0); i++ )
   {
      if ( (currency == "" || (currency != "" && upperCase( arraySource[i][1] ) == currency)) && 
           (date == 0 || (date > 0 && date == lastBarTime(StrToTime(arraySource[i][2]), PERIOD_D1) ) ) )
      {
         if ( (impact & XML_LOW && upperCase( arraySource[i][3] ) == "LOW") || 
              (impact & XML_MEDIUM && upperCase( arraySource[i][3] ) == "MEDIUM") || 
              (impact & XML_HIGH && upperCase( arraySource[i][3] ) == "HIGH") || 
              (impact & XML_HOLIDAY && upperCase( arraySource[i][3] ) == "HOLIDAY") )
         {
            index = addIndexStringArrayBD( arrayDest );
            arrayDest[index][0] = arraySource[i][0];
            arrayDest[index][1] = arraySource[i][1];
            arrayDest[index][2] = arraySource[i][2];
            arrayDest[index][3] = arraySource[i][3];
            arrayDest[index][4] = arraySource[i][4];
            arrayDest[index][5] = arraySource[i][5];
         }
      }
   }

   return( index + 1 );
}
//+------------------------------------------------------------------+
//| getRSSfunction
//+------------------------------------------------------------------+
int getRSS( string RSS_url, string &array[][] )
{
   ArrayResize( array, 0 );

   string webRss = ReadWebResource( RSS_url );
   int i; 
   int hour;
   int minute;
   int dailyTime;
   int index;
   string webResData[];
   int stringsCount = ArrayFromString( webResData, webRss, ">" );
   string tags[];       // array for storing the tags
   int startPos[][2];   // tag start coordinates
   int endPos[][2];     // tag end coordinates

   FillTagStructure( tags, startPos, endPos, webResData );

   string currTag;
   int go[1][2];
   int end[1][2];

   // array destination description
   // 0 = title
   // 1 = country
   // 2 = datetime
   // 3 = impact
   // 4 = forecast
   // 5 = previous

   for ( i = 0; i < ArraySize( tags ); i++ )
   {
      currTag = tags[i];

      if ( currTag == "<event>" )
      {
         go[0][0] = -1;
         go[0][1] = -1;
         index = addIndexStringArrayBD( array );
      }

      if ( currTag == "<title>" )
      {
         go[0][0] = endPos[i][0];
         go[0][1] = endPos[i][1];
      }

      if ( currTag == "</title>" )
      {
         end[0][0] = startPos[i][0];
         end[0][1] = startPos[i][1];
         array[index][0] = GetContent(webResData, go, end);
      }

      if ( currTag == "<country>" )
      {
         go[0][0] = endPos[i][0];
         go[0][1] = endPos[i][1];
      }

      if ( currTag == "</country>" )
      {
         end[0][0] = startPos[i][0];
         end[0][1] = startPos[i][1];
         array[index][1] = GetContent(webResData, go, end);
      }

      if ( currTag == "<date>" )
      {
         go[0][0] = endPos[i][0];
         go[0][1] = endPos[i][1];
      }

      if ( currTag == "</date>" )
      {
         end[0][0] = startPos[i][0];
         end[0][1] = startPos[i][1];
         dailyTime = formatDate( stringTrimFrom( GetContent(webResData, go, end), 9, 3 ) );
      }

      if ( currTag == "<time>" )
      {
         go[0][0] = endPos[i][0];
         go[0][1] = endPos[i][1];
      }

      if ( currTag == "</time>" )
      {
         end[0][0] = startPos[i][0];
         end[0][1] = startPos[i][1];
         formatTime( stringTrimFrom( GetContent(webResData, go, end), 9, 3 ), hour, minute );
         array[index][2] = TimeToStr( dailyTime + (hour * 3600) + (minute * 60) + daylightSavings(), TIME_DATE|TIME_SECONDS );
      }

      if ( currTag == "<impact>" )
      {
         go[0][0] = endPos[i][0];
         go[0][1] = endPos[i][1];
      }

      if ( currTag == "</impact>" )
      {
         end[0][0] = startPos[i][0];
         end[0][1] = startPos[i][1];
         array[index][3] = stringTrimFrom( GetContent(webResData, go, end), 9, 3 );
      }

      if ( currTag == "<forecast>" )
      {
         go[0][0] = endPos[i][0];
         go[0][1] = endPos[i][1];
      }

      if ( currTag == "</forecast>" )
      {
         end[0][0] = startPos[i][0];
         end[0][1] = startPos[i][1];
         array[index][4] = stringTrimFrom( GetContent(webResData, go, end), 9, 3 );
      }

      if ( currTag == "<previous>" )
      {
         go[0][0] = endPos[i][0];
         go[0][1] = endPos[i][1];
      }

      if ( currTag == "</previous>" )
      {
         end[0][0] = startPos[i][0];
         end[0][1] = startPos[i][1];
         array[index][5] = stringTrimFrom( GetContent(webResData, go, end), 9, 3 );
      }

      if ( currTag == "</weeklyevents>" )
         break;
   }

   string arrayTemp[][6];
   ArrayCopy( arrayTemp, array );
   ArrayResize( array, 0 );
   for ( i = 0; i < ArrayRange(arrayTemp, 0) + 1; i++ )
   {
      if ( StrToTime( arrayTemp[i][2] ) >= lastBarTime( 0, PERIOD_W1 ) )
      {
         index = addIndexStringArrayBD( array );
         array[index][0] = arrayTemp[i][0];
         array[index][1] = arrayTemp[i][1];
         array[index][2] = arrayTemp[i][2];
         array[index][3] = arrayTemp[i][3];
         array[index][4] = arrayTemp[i][4];
         array[index][5] = arrayTemp[i][5];
      }
   }

   return( index + 1 );
}
//+------------------------------------------------------------------+
//| 
//+------------------------------------------------------------------+
int ArrayFromString( string &webResData[], string inputStr, string divider )
{
   if ( inputStr == "" )
   {
     Print( "Input string is not set" ); 
     return(0);
   }

   if ( divider == "" )
   {
      Print( "Separator is not set" ); 
      return(0);
   }

   int i;
   int stringCounter = 0;
   string tmpChar;
   string tmpString;
   string tmpArr[64000];
   int inputStringLen = StringLen(inputStr);

   for ( i = 0; i < inputStringLen; i++ )
   {
      tmpChar = StringSubstr(inputStr, i, 1);
      tmpString = tmpString + tmpChar;
      tmpArr[stringCounter] = tmpString; 
      if ( tmpChar == divider )
      {          
          stringCounter++;
          tmpString = "";
      }               
   }

   if ( stringCounter > 0 )
   {
      ArrayResize(webResData, stringCounter);   
      for ( i = 0; i < stringCounter; i++ )
         webResData[i] = tmpArr[i];
   }

   return ( stringCounter );
}
//+------------------------------------------------------------------+
//|  fill the structure of tags                                      |
//+------------------------------------------------------------------+
void FillTagStructure( string &structure[], //created structure of tags
                       int &go[][], // tag start (string, position)
                       int &end[][], // tag end (string, position)
                       string &array[] ) // source html text
{
   int array_Size = ArraySize(array);

   ArrayResize(structure, 10000);
   ArrayResize(go, 10000);
   ArrayResize(end, 10000);

   int i = 0;
   int line;
   int posOpen;
   int pos_;
   int posClose;
   int tagCounter;
   int currPos = 0;
   string currString;
   string tag;
   int curCapacity = 10000;

   while (i < array_Size)
   {
      if ( tagCounter >= curCapacity )                      //  if the number of tags has exceeded 
      {                                                     //  storage 10000
         ArrayResize(structure, curCapacity + 10000);    //  increase storage 10000
         ArrayResize(go, curCapacity + 10000);        //  increase the size of the starting positions' array
         ArrayResize(end, curCapacity + 10000);          //  increase the size of the end positions' array       
         curCapacity += 10000;                           //  remember the new 10000
      }

      currString = array[i];                                // take the current string
      //Print(currString);
      posOpen = StringFind(currString, "<", currPos);       // look for the first "<" occurrence from currPos position
      if ( posOpen == -1 )                                  // not found
      {
         line = i;                                          // move to the next string
         currPos = 0;                                       //  search from the start in the new string
         i++;
         continue;                                          // return to the loop start
      }

      //  if this point is reached, "<" has been found     
      pos_ = StringFind(currString, " ", posOpen);          //  then search for space
      posClose = StringFind(currString, ">", posOpen);      //  search for the closing bracket 

      if ( (pos_ == -1) && (posClose != -1) )               //  there is no space but the bracket has been found
      {
         tag = StringSubstr(currString, posOpen, posClose - posOpen) + ">";
         // tag created
         structure[tagCounter] = tag;                       //  write it to the tags array
         setPositions(go, end, tagCounter, i, posOpen, i, posClose+1);
         tagCounter++;                                      //  increase the counter of found tags
         currPos = posClose;                                //  next search for the new tag starts here
         continue;                                          //   from posClose position where the closing bracket has been found
      }

      //   if we reached this place, both space and closing bracket have been found
      if ( (pos_ != -1) && (posClose != -1) )
      {
         if ( pos_ > posClose )                             //  space located after the brackets
         {
            tag = StringSubstr(currString, posOpen, posClose - posOpen) + ">";
            // tag created
            structure[tagCounter] = tag;                    //  write it to the tags array
            setPositions(go, end, tagCounter, i, posOpen, i, posClose+1);
            tagCounter++;                                   //  increase the counter of found tags
            currPos = posClose;                             //  next search for the new tag starts here
            continue;                                       //   from posClose position where the closing bracket has been found
         }

         //  space is located before the closing bracket
         if ( pos_ < posClose )
         {
            tag = StringSubstr(currString, posOpen, pos_ - posOpen) + ">";
            // tag created
            structure[tagCounter] = tag;                 //  write it to the tags array
            setPositions(go, end, tagCounter, i, posOpen, i, posClose+1);
            tagCounter++;                                //  increase the counter of found tags
            currPos = posClose;                          //  next search for the new tag starts here
            continue;                                    //   from posClose position where the closing bracket has been found
         }
      }

      //   if we reached this place, neither space nor closing bracket have been found
      if ( (pos_ == -1) && (posClose == -1) )
      {
         tag = StringSubstr(currString, posOpen) + ">";  //  create the tag using present elements
         structure[tagCounter] = tag;                    //  write it to the tags array

         while ( posClose == -1 )                          //  and arrange the loop of searching for
         {                                               //  the first closing bracket
            i++;                                         //  increase the string counter
            currString = array[i];                       //  calculate the new string
            posClose = StringFind(currString, ">");      //  and search for the closing bracket in it
         }

         setPositions(go, end, tagCounter, i, posOpen, i, posClose+1);
         tagCounter++;                                   //  increase the counter of found tags
         currPos = posClose;                             //  it has probably been found, set the initial position
      }                                                  //  for searching for the new tag
   }

   ArrayResize( structure, tagCounter );                   //  cut the size of the tags array down to the number of the found

   return;   
}
//+------------------------------------------------------------------+
//| write tag coordinates to the appropriate arrays                  |
//+------------------------------------------------------------------+
void setPositions( int &st[][], int &en[][], int counter, int stLine, int stPos, int enLine, int enPos )
{
   st[counter][0] = stLine;
   st[counter][1] = stPos;

   en[counter][0] = enLine;
   en[counter][1] = enPos;

   return;
}
//+------------------------------------------------------------------+

and the compiling error

'ArrayFromString' - ambiguous call to overloaded function with the same parameters      CF_XML_Lib.mq4  67      23
'FillTagStructure' - ambiguous call to overloaded function with the same parameters     CF_XML_Lib.mq4  72      4
'setPositions' - ambiguous call to overloaded function with the same parameters CF_XML_Lib.mq4  312     10
'setPositions' - ambiguous call to overloaded function with the same parameters CF_XML_Lib.mq4  326     13
'setPositions' - ambiguous call to overloaded function with the same parameters CF_XML_Lib.mq4  338     13
'setPositions' - ambiguous call to overloaded function with the same parameters CF_XML_Lib.mq4  358     10

thanks

eugenio

 

I solved the issue. Thanks.

 

Hello,

 

 I have an older EA template (using EA with libraries and include files) that is no longer working in current MT4 versions. I'm getting "ambiguous call to overloaded function with the same parameters" error when compiling.

 I'm not a programmer, but I can read and write some code. My problem is that I can code some simple routine things but I don't have a good fundamental understanding of MQL language.

 Can anyone help? 

 

I have a feeling that I need to include more code for a comprehensive solution, but can anyone at-least try to explain me what is the reason for this error and point me to right direction? 

  

 Line below is the one causing the error in main EA code. Library and Include files seem to compile just fine

 if ( !FilterSetups( martingale, fibomartingale,...

 Code from EA:

//if all filters are passed successfully //
   if ( !FilterSetups( martingale, fibomartingale,
                       maxspread, pt, //max spread filter parameters
                       _buy_trades + _sell_trades, max_martingale_trades, maxtrades, maxtradesnet, //max trades filter parameters
                       Symbol() , magic_number, closeall, //closeAll trades filter parameters
                       //sleep minutes after x losses filter parameters
                       sleepafterxlosses, xlosses, sleepminutes, last_minutes_xlosses_time,
                       //sleep x mintes between trades filter parameters
                       minutes_between_trades, last_minutes_bt_time,
                       //sleep x bars between trades filter parameters
                       bars_between_trades, bars_counter,
                       //time filter parameters
                       usetimefilter, tradesunday, mondayfilter, mondayhour, mondayminute,
                       fridayfilter, fridayhour, fridayminute, weekfilter, starthour, startminute, endhour, endminute,
                       //news time filter parameters
                       newsfilter, minutesbefore, minutesafter, impacthigh, impactmedium, impactlow )
                      ) {  

 

 Code from Include:

 

//check Restrictions for new SETUPS, if there are some restrictions, return true, DO NOT open new trades, otherwise return false
   bool FilterSetups( bool martingale, bool fibomartingale,
                      double maxspread, double point, //max spread filter parameters
                      int _trades_open, int max_martingale_trades, int maxtrades, int maxtradesnet, //max trades filter parameters
                      string symbol, int magic, bool closeall_activated, //closeAll trades filter parameters
                      //sleep minutes after x losses filter parameters
                      bool sleepafterxlosses, int xlosses, int sleepminutes,
                      datetime last_minutes_xlosses_time,
                      //sleep x mintes between trades filter parameters
                      int minutes_between_trades, datetime last_minutes_bt_time,
                      //sleep x bars between trades filter parameters
                      int bars_between_trades, int bars_counter,
                      //time filter parameters
                      bool usetimefilter, bool tradesunday,
                      bool mondayfilter, int mondayhour, int mondayminute,
                      bool fridayfilter, int fridayhour, int fridayminute,
                      bool weekfilter, int starthour, int startminute, int endhour, int endminute,
                      //news time filter parameters
                      bool newsfilter, int minutesbefore, int minutesafter, bool impacthigh, bool impactmedium, bool impactlow );

Code from Library:

bool FilterSetups( bool martingale, bool fibomartingale,
                   double maxspread, double point, //max spread filter parameters
                   int _trades_open, int max_martingale_trades, int maxtrades, int maxtradesnet, //max trades filter parameters
                   string symbol, int magic, bool closeall_activated, //closeAll trades filter parameters
                   //sleep minutes after x losses filter parameters
                   bool sleepafterxlosses, int xlosses, int sleepminutes,
                   datetime last_minutes_xlosses_time,
                   //sleep x mintes between trades filter parameters
                   int minutes_between_trades, datetime last_minutes_bt_time,
                   //sleep x bars between trades filter parameters
                   int bars_between_trades, int bars_counter,
                   //time filter parameters
                   bool usetimefilter,
                   bool tradesunday,
                   bool mondayfilter, int mondayhour, int mondayminute,
                   bool fridayfilter, int fridayhour, int fridayminute,
                   bool weekfilter, int starthour, int startminute, int endhour, int endminute,
                   //news time filter parameters
                   bool newsfilter, int minutesbefore, int minutesafter, bool impacthigh, bool impactmedium, bool impactlow )
{
 
luckyluke72:

Hello,

 

 I have an older EA template (using EA with libraries and include files) that is no longer working in current MT4 versions. I'm getting "ambiguous call to overloaded function with the same parameters" error when compiling.

 I'm not a programmer, but I can read and write some code. My problem is that I can code some simple routine things but I don't have a good fundamental understanding of MQL language.

 Can anyone help? 



Wow, that is a lot of arguments for one function, no wonder it is giving you issues... I would start by simplifying your code and breaking it up into smaller functions with less arguments. That should help you pin down where the issue is laying at. Just a general programming advice
 

the reason for this error is: you have the same function twice

1) library folder . 2) include folder.

remove one of them !

 

Thank you all, I appreciate your help!

 

gjol: I compiled the exact same code about 1 yr ago and it was compiled just fine with library and include as they are. Therefore the same function twice should not be the problem, unless the new MT4 versions have changed so that they don't accept it, which ofcourse can be the case...

 
luckyluke72:

Thank you all, I appreciate your help!

 

gjol: I compiled the exact same code about 1 yr ago and it was compiled just fine with library and include as they are. Therefore the same function twice should not be the problem, unless the new MT4 versions have changed so that they don't accept it, which ofcourse can be the case...



try and find out
 
luckyluke72:

Thank you all, I appreciate your help!

 

gjol: I compiled the exact same code about 1 yr ago and it was compiled just fine with library and include as they are. Therefore the same function twice should not be the problem, unless the new MT4 versions have changed so that they don't accept it, which ofcourse can be the case...

Previous versions did not support overloaded functions, I would guess the old compiler ignored one of the identical functions. As the new compiler supports overloaded functions it is expecting one of them to have different parameters. You could just rename one of the functions, if it is not called it won't be compiled.
Reason: