Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Start earning money!
fulltilt
367
fulltilt 2013.10.28 08:57  
Thirteen:

Try:

if (Month() == 1 && Day() >= 30) return (0);


it works ... I thought day() returns 0-7 only - sorry my mistake ;-)

        if (!TradeMonthEnd && Month() == 1 && Day() >= 30) return(0);
        if (!TradeMonthEnd && Month() == 2 && Day() >= 27) return(0);
        if (!TradeMonthEnd && Month() == 3 && Day() >= 30) return(0);
        if (!TradeMonthEnd && Month() == 4 && Day() >= 29) return(0);
        if (!TradeMonthEnd && Month() == 5 && Day() >= 30) return(0);
        if (!TradeMonthEnd && Month() == 6 && Day() >= 29) return(0);
        if (!TradeMonthEnd && Month() == 7 && Day() >= 30) return(0);
        if (!TradeMonthEnd && Month() == 8 && Day() >= 30) return(0);
        if (!TradeMonthEnd && Month() == 9 && Day() >= 29) return(0);
        if (!TradeMonthEnd && Month() == 10 && Day() >= 30) return(0);
        if (!TradeMonthEnd && Month() == 11 && Day() >= 29) return(0);
        if (!TradeMonthEnd && Month() == 12 && Day() >= 30) return(0);
ossi99
3
ossi99 2016.07.25 15:36  

CHECK ANY MONTH WITH THIS CODE:

int DaysOfMonth(int cYear = 2016, int cMonth = 2, int cDay = 29) {

   if (cYear < 1969 || cMonth < 1 || cMonth > 12 || cDay < 1 || cDay > 31) return(0);

   datetime xDate;

   int result = 0;

   for (int i = cDay+1; i <= cDay + 31; i++) {

      xDate = StrToTime(IntegerToString(cYear)+"."+IntegerToString(cMonth)+"."+IntegerToString(i));

     if ( TimeDay(xDate) > cDay ) result = i;

     else break;

   }

   return(result);

}

/ /12
To add comments, please log in or register