How to get the current date out of MQL5

 

Hello everyone

Im struggling with getting the date out of mql5... ive read all that mql5 instructions... but im too stupid to get it right as it seems.

I initiate these two functions:

bool TradeDayOfWeek()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   int day = tm.day_of_week;
   return((TradeMonday && day == 1)
   || (TradeTuesday && day == 2)
   || (TradeWednesday && day == 3)
   || (TradeThursday && day == 4)
   || (TradeFriday && day == 5)
   || (TradeSaturday && day == 6)
   || (TradeSunday && day == 0));
  }
  
int TradeDayOfMonth()
  {
   MqlDateTime td;
   TimeCurrent(td);
   int tag = td.day;
   return(tag);
  }

First one just gives true or false.

Second one should give out 1-31 ... but it doesnt... why?

It is used to open trades afterwards like that here:

&& (5 < TradeDayOfMonth() < 25) ... one of many conditions.

Should not trade the first 5 days of the month and from 25th to end of month.


Please help. Im loosing too much hair on such an easy dumb task.


Thank you very much in advance

Best regards and have a nice day. :)

 
by the way... the first function works... so i am able to select monday-sunday trading or not... but im not able to block the end-start of month days for some reason... my code does not give errors... but it opens on 03.01 where it should open from 05.01 on for example.
 
  • Please stop using vulgar language. Have some pride in how you write.
  • Your topic has been moved to the section: Expert Advisors and Automated Trading — In the future, please consider which section is most appropriate for your query.
  • Please EDIT your post and use the CODE button (Alt-S) when inserting code.
    Code button in editor
    Hover your mouse over your post and select "edit" ... 
 
Fernando Carreiro #:
  • Please stop using vulgar language. Have some pride in how you write.
  • Your topic has been moved to the section: Expert Advisors and Automated Trading — In the future, please consider which section is most appropriate for your query.
  • Please EDIT your post and use the CODE button (Alt-S) when inserting code.
    Hover your mouse over your post and select "edit" ... 
im sorry :D was very stressed at that point :D
Reason: