Download MetaTrader 5

'}' - not all control paths return a value

To add comments, please log in or register
hana
9
hana  

hello

I am using a expert in  MetaTrader 4 and I need it to use it in 5. I used a converter here xxxxxx. and it has an error and 2 warnings.

 

OnDeinit function declared with wrong type or/and parameters 150 6

'}' - not all control paths return a value 144 1

implicit conversion from 'number' to 'string'   48 161

 

I attached the source code and the converted one. I will be very very glad if someone help me out. by the way I know nothing about these languages (mq4 and mq5)

Thanks in advance 

Alain Verleyen
Moderator
32394
Alain Verleyen  
  • You have to ask to the owner of the site you used.
  • I removed the reference to the site as advertising isn't allowed on this forum.
  • If you want quality work conversion, you can use the Jobs section.
enbo lu
Moderator
1940
enbo lu  

'}' - not all control paths return a value 144 1

 ----that means maybe some "if else" block does not consider all the possibilities as a return.

Kourosh Davallou
44785
Kourosh Davallou  
hana:

hello

I am using a expert in  MetaTrader 4 and I need it to use it in 5. I used a converter here xxxxxx. and it has an error and 2 warnings.

 

OnDeinit function declared with wrong type or/and parameters 150 6

'}' - not all control paths return a value 144 1

implicit conversion from 'number' to 'string'   48 161

 

I attached the source code and the converted one. I will be very very glad if someone help me out. by the way I know nothing about these languages (mq4 and mq5)

Thanks in advance 

Hi

//+------------------------------------------------------------------+
//|                                                       elitte.mq5 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
 int handle;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
     if(handle<1)
      {
      Print("can't open file error-",GetLastError());
      return(0);
      }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
    FileClose(handle);
  }
double Ask;
double Bid;
double Open[];
double Close[];
double High[];
double Low[];
datetime Time[];
long Volume[];

void OnTick()
  {
//---- 
  
   int cnt;
   int _year = 2002;
   int _month = 1;
   int _day = 1;
   string strline;
   string name_file;
   
   MqlTick last_tick;
   SymbolInfoTick(_Symbol,last_tick);
   Ask=last_tick.ask;
   Bid=last_tick.bid;
  
   ArraySetAsSeries(Close,true);
   CopyClose(_Symbol,_Period,0,Bars(_Symbol,_Period),Close);
   ArraySetAsSeries(Open,true);
   CopyOpen(_Symbol,_Period,0,Bars(_Symbol,_Period),Open);
   ArraySetAsSeries(Low,true);
   CopyLow(_Symbol,_Period,0,Bars(_Symbol,_Period),Low);
   ArraySetAsSeries(High,true);
   CopyHigh(_Symbol,_Period,0,Bars(_Symbol,_Period),High);
   ArraySetAsSeries(Time,true);
   CopyTime(_Symbol,_Period,0,Bars(_Symbol,_Period),Time);
   ArraySetAsSeries(Volume,true);
   CopyTickVolume(_Symbol,_Period,0,Bars(_Symbol,_Period),Volume);
   name_file = StringSubstr(_Symbol, 0, 1) + StringSubstr(_Symbol, 1, 1) +StringSubstr(_Symbol, 2, 1) +StringSubstr(_Symbol, 3, 1) +StringSubstr(_Symbol, 4, 1) +IntegerToString( _Period)+ ".prn";
   //Print("name_file=", name_file);
   handle = FileOpen(name_file , FILE_CSV|FILE_WRITE, "\t");
  
   strline = "<DTYYYYMMDD>,<TIME>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>";
   FileWrite(handle, strline);
   for (cnt=1000;cnt>=0;cnt--)
      {
      if (_Period < 1440)
         {
         strline = DoubleToString(_year,0);
         if (_month < 10)
            strline = strline + "0" + DoubleToString(_month,0);
         else
            strline = strline + DoubleToString(_month,0);
      
         if (_day < 10)
            strline = strline + "0" + DoubleToString(_day,0);
         else
            strline = strline + DoubleToString(_day,0);
         }
      else
         {
         strline = DoubleToString(Time[cnt],TIME_DATE|TIME_SECONDS);
         strline = StringSubstr(strline,0,4) + StringSubstr(strline,5,2) + StringSubstr(strline,8,2);
//         Print("strline=", strline);
         }
      strline = strline + ",0," + DoubleToString(Open[cnt],4) + "," + DoubleToString(High[cnt],4) + "," + DoubleToString(Low[cnt],4) + "," + DoubleToString(Close[cnt],4) + "," + DoubleToString(Volume[cnt],0);
      FileWrite(handle, strline);
      // Start of build virtual date.
      if (_Period < 1440)
         {
         if (_day < 28) 
            _day++; 
         else 
            {
            _day = 1;
            _month++;
            if (_month > 12)
               {
               _month = 1;
               _year++;
               }
            }
         }
      // End of build virtual date.
      }
  

//----
  
  }
//+------------------------------------------------------------------+
Kourosh Davallou
44785
Kourosh Davallou  
//+------------------------------------------------------------------+
//|                                                       elitte.mq5 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
 int handle;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

  string name_file = StringSubstr(_Symbol, 0, 1) + StringSubstr(_Symbol, 1, 1) +StringSubstr(_Symbol, 2, 1) +StringSubstr(_Symbol, 3, 1) +StringSubstr(_Symbol, 4, 1) +IntegerToString( _Period)+ ".csv";
  
    handle = FileOpen(name_file , FILE_CSV|FILE_WRITE, "\t");
     if(handle<1)
      {
      Print("can't open file error-",GetLastError());
      return(0);
      }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
    FileClose(handle);
  }
double Ask;
double Bid;
double Open[];
double Close[];
double High[];
double Low[];
datetime Time[];
long Volume[];

void OnTick()
  {
//---- 
  
   int cnt;
   int _year = 2002;
   int _month = 1;
   int _day = 1;
   string strline;
   string name_file;
   
   MqlTick last_tick;
   SymbolInfoTick(_Symbol,last_tick);
   Ask=last_tick.ask;
   Bid=last_tick.bid;
  
   ArraySetAsSeries(Close,true);
   CopyClose(_Symbol,_Period,0,Bars(_Symbol,_Period),Close);
   ArraySetAsSeries(Open,true);
   CopyOpen(_Symbol,_Period,0,Bars(_Symbol,_Period),Open);
   ArraySetAsSeries(Low,true);
   CopyLow(_Symbol,_Period,0,Bars(_Symbol,_Period),Low);
   ArraySetAsSeries(High,true);
   CopyHigh(_Symbol,_Period,0,Bars(_Symbol,_Period),High);
   ArraySetAsSeries(Time,true);
   CopyTime(_Symbol,_Period,0,Bars(_Symbol,_Period),Time);
   ArraySetAsSeries(Volume,true);
   CopyTickVolume(_Symbol,_Period,0,Bars(_Symbol,_Period),Volume);
   //Print("name_file=", name_file);
  
  
   strline = "<DTYYYYMMDD>,<TIME>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>";
   FileWrite(handle, strline);
 
   for (cnt=1000;cnt>=0;cnt--)
      {
      if (_Period < 1440)
         {
         strline = DoubleToString(_year,0);
            printf(" 111 strline= %s", strline);
         if (_month < 10)
            strline = strline + "0" + DoubleToString(_month,0);
         else
            strline = strline + DoubleToString(_month,0);
      
         if (_day < 10)
            strline = strline + "0" + DoubleToString(_day,0);
         else
            strline = strline + DoubleToString(_day,0);
         }
      else
         {
         strline = TimeToString(Time[cnt],TIME_DATE|TIME_SECONDS);
         strline = StringSubstr(strline,0,4) + StringSubstr(strline,5,2) + StringSubstr(strline,8,2);
         printf("strline= %s", strline);
         }
      strline = strline + ",0," + DoubleToString(Open[cnt],4) + "," + DoubleToString(High[cnt],4) + "," + DoubleToString(Low[cnt],4) + "," + DoubleToString(Close[cnt],4) + "," + DoubleToString(Volume[cnt],0);
      FileWrite(handle, strline);
      // Start of build virtual date.
      if (_Period < 1440)
         {
         if (_day < 28) 
            _day++; 
         else 
            {
            _day = 1;
            _month++;
            if (_month > 12)
               {
               _month = 1;
               _year++;
               }
            }
         }
      // End of build virtual date.
      }
  

//----
  
  }
//+------------------------------------------------------------------+

Kourosh Davallou
44785
Kourosh Davallou  
file name
 string name_file = StringSubstr(_Symbol, 0, 1) + StringSubstr(_Symbol, 1, 1) +StringSubstr(_Symbol, 2, 1) +StringSubstr(_Symbol, 3, 1) +StringSubstr(_Symbol, 4, 1) +IntegerToString( _Period)+ ".csv";
  

To add comments, please log in or register