MQL4 code into MQL5

 

Hi,

Is there any simple tool that i could transform my MQL4 code into MQL5? I get an error that main function should return a value. And not clear what to use as a value that i can use properly this mql4 code.


int Count=0;  
extern   int  timeA          =  23;
extern   int  timeB         =  8;
extern int      TP                  = 30;
extern int      SL                  = 10;
extern double   Lots                = 0.1;
extern int    RSI_Period           = 14;
extern   double   RSI_BuyB          =  30;
extern   double   RSI_SellB         =  70;
extern int MagicNumber = 0;
#define LAST_BAR 1
extern bool CheckOncePerBar = true;
datetime CurrentTimeStamp;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+


void init()
  {
//----
     //CurrentTimeStamp = Time[0];
   init();
  //return;
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+

  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
 
                        
   
  if(CheckOncePerBar == true)
  {
   int BarShift = 1;
       if(CurrentTimeStamp != Time[0])
     {
         CurrentTimeStamp = Time[0];
         bool NewBar = true;
      }
       else NewBar = false;
        }
      else
      {
    NewBar = true;
    BarShift = 0;
    }
  
   
   if (NewBar)  
    {
       int    Cur_Hour=Hour();  
      
       bool trading_time1 = Cur_Hour >= timeA;
       bool trading_time2 = Cur_Hour < timeB;
       double rsi_Now    =  iRSI(Symbol(),Period(),RSI_Period,PRICE_CLOSE,LAST_BAR); 
       double rsi_Then   =  iRSI(Symbol(),Period(),RSI_Period,PRICE_CLOSE,LAST_BAR+1); 
      
       bool bullish = rsi_Now < RSI_BuyB; 
       bool bearish = rsi_Then > RSI_SellB; 
    
    if (trading_time1)
       {
        if (bullish) OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-SL*Point,Bid+TP*Point,"Buy", MagicNumber, 0, Green);
         if (bearish) OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+SL*Point,Ask-TP*Point,"Sell", MagicNumber,0, Red);
       }
    if (trading_time2)
       { if (bullish) OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-SL*Point,Bid+TP*Point,"Buy", MagicNumber, 0, Green);
         if (bearish) OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+SL*Point,Ask-TP*Point,"Sell", MagicNumber,0, Red);
       }  
       
    }
   
   int Error=GetLastError();
      if(Error==130){Alert("Wrong stops. Retrying."); }
      if(Error==133){Alert("Trading prohibited.");}
      if(Error==2){Alert("Common error.");}
      if(Error==146){Alert("Trading subsystem is busy. Retrying."); Sleep(50); } 
   
//   start();
//----
   return;
  }
//+------------------------------------------------------------------+


void deinit()
 {
//----
    deinit();
//   Alert ("Funct. deinit() triggered at exit"); 
//   return;
  }
 
orangutangas:

Hi,

Is there any simple tool that i could transform my MQL4 code into MQL5? I get an error that main function should return a value. And not clear what to use as a value that i can use properly this mql4 code.

No simple tool.
 
ty
 
orangutangas:

Hi,

Is there any simple tool that i could transform my MQL4 code into MQL5? I get an error that main function should return a value. And not clear what to use as a value that i can use properly this mql4 code.

Migrating from MQL4 to MQL5 - MQL5 Articles Not perfect but a good start.