- There is no problem with the MQLDateTime.
How To Ask Questions The Smart Way. (2004)
Don't rush to claim that you have found a bug.
Questions Not To Ask
My program doesn't work. I think system facility X is broken.It is almost always your code.
- The second parameter of SymbolInfoSessionTrade requires a ENUM_DAY_OF_WEEK.
You are passing an int. int Day_of_week = DateTimeStructure.day_of_week ;
Pass the correct types to your function calls. ENUM_DAY_OF_WEEK Day_of_week = ENUM_DAY_OF_WEEK(DateTimeStructure.day_of_week);
#define DoWi(t) ((int)(((t-259200)%604800)/86400)) // (int)Day of Week Su=0,Mo=1,... ... int wkd = DoWi(TimeTradeServer());
Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Библиотеки: TimeDaylightCorrections
fxsaber, 2021.09.20 12:28
#define DAY (24 * 3600) #define WEEK 7 ENUM_DAY_OF_WEEK TimeDayOfWeek( const datetime time ) { return((ENUM_DAY_OF_WEEK)((time / DAY + THURSDAY) % WEEK)); }
Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Особенности языка mql5, тонкости и приёмы работы
fxsaber, 2017.02.25 16:39
bool SessionTrade( const string Symb )
{
datetime TimeNow = ::TimeTradeServer();
const ENUM_DAY_OF_WEEK DayOfWeek = TimeDayOfWeek(TimeNow);
TimeNow %= 24 * 60 * 60;
bool Res = false;
datetime From, To;
for (int i = 0; (!Res) && ::SymbolInfoSessionTrade(Symb, DayOfWeek, i, From, To); i++)
Res = ((From <= TimeNow) && (TimeNow < To));
return(Res);
}
{
datetime TimeNow = ::TimeTradeServer();
const ENUM_DAY_OF_WEEK DayOfWeek = TimeDayOfWeek(TimeNow);
TimeNow %= 24 * 60 * 60;
bool Res = false;
datetime From, To;
for (int i = 0; (!Res) && ::SymbolInfoSessionTrade(Symb, DayOfWeek, i, From, To); i++)
Res = ((From <= TimeNow) && (TimeNow < To));
return(Res);
}

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all, at row 5 I have the following error: "Day_of_week" cannot convert ENUM.
When I print int Day_of_week is 0 (today is Sunday).
Could you help me? Thank you!