TRADING HOURS MQL4 CODE

To add comments, please log in or register
Raymond Philip
20
Raymond Philip  
int start()
{

   int GMT_HOUR = TimeHour(TimeGMT());
   int GMT_MINUTE = TimeMinute(TimeGMT());
   
   //TradingHours (00:00-20:59)
   if(GMT_HOUR >= 00 && GMT_HOUR <= 20 && GMT_MINUTE >= 00)
   {
      //OpenOrders (08:00-12:59)
      if(GMT_HOUR >= 08 && GMT_HOUR <= 12 && GMT_MINUTE >= 00)
      {
         //Buy
         if(Ask > SlowMA && BuyTicket == 0)
         {            
		blablabla
else Print("Out Of Trading Hour");
   

is there anything wrong with this block of code? 

Because it always Prints out: Out Of Trading Hour

because it always goes to my "else"

lippmaje
592
lippmaje  
There are some braces '}' missing, so it's not complete and won't compile. Because 'blablabla' definitely doesn't compile. Because of compiler.
Mehrdad Jeddi
26500
Mehrdad Jeddi  

Hi,

It would be such :(as @lippmaje mentioned some braces '}' characters are missing,they would be defined otherwise the compiler will show error !)

int start()
{

   int GMT_HOUR = TimeHour(TimeGMT());
   int GMT_MINUTE = TimeMinute(TimeGMT());
   
   //TradingHours (00:00-20:59)
   if(GMT_HOUR >= 00 && GMT_HOUR <= 20 && GMT_MINUTE >= 00)
   {
      //OpenOrders (08:00-12:59)
      if(GMT_HOUR >= 08 && GMT_HOUR <= 12 && GMT_MINUTE >= 00)
      {
         //Buy
         if(Ask > SlowMA /*&& BuyTicket == 0*/)
         {
           //Do something 
         }
      }
      else Print("Out Of OpenOrders (08:00-12:59))");
   }            
   else Print("Out Of Trading Hour (00:00-20:59)");

 return 0;
}

Regards !

To add comments, please log in or register