elzinkhana #: How can I find out the number of the first trading day in January of any year using MQL4.5?
/********************Script program start function*******************/voidOnStart()
{
datetime newYear[];
int bars = Bars(_Symbol, PERIOD_D1, D'2020.01.01', TimeCurrent())-1;
CopyTime(_Symbol, PERIOD_D1, bars, 1, newYear);
printf("Первый торговый день %s %s", EnumToString(ENUM_DAY_OF_WEEK((newYear[0]/PeriodSeconds(PERIOD_D1)+4)%7)), TimeToString(newYear[0]));
}/******************************************************************/
Result
2023.05.1413:37:02.118 !!0 (EURUSD,D1) Первый торговый день MONDAY2022.01.0300:002023.05.1413:38:18.547 !!0 (EURUSD,D1) Первый торговый день MONDAY2021.01.0400:002023.05.1413:38:35.906 !!0 (EURUSD,D1) Первый торговый день THURSDAY2020.01.0200:00
What made the decision that it was a trading day? Is the idea that there were quotes available? And if there were quotes but you couldn't trade - I think that's the question.
Open MT and take a look. Why ask such questions without looking? The bar is there with all the attributes of OHLC. Everything else is just your imagination.....
I noticed that trading days start in January in one of three variants: 2 January or 3 January or 4 January. And I was even able to write a subroutine in MQL4 to determine the date of the first trading day in the new year.
int inp_Year=2016; //put the number of the year of interest into the variable datetimefirst_day_New_Year=StringToTime(IntegerToString(inp_Year)+".01.02 00:00"); //variable where we will record the exact date of the beginning of the trading year, if the trading of a certain year started on the 2nd of January, if the 2nd of January was a weekday if (TimeDayOfWeek(first_day_New_Year)==0) first_day_New_Year=StringToTime(StringSubstr(TimeToString(first_day_New_Year),0,4)+".01.03 00:00"); //3 January started trading of a certain year, if 2 January was Sunday if (TimeDayOfWeek(first_day_New_Year)==6) first_day_New_Year=StringToTime(StringSubstr(TimeToString(first_day_New_Year),0,4)+"".01.04 00:00"); //4 January trades of a certain year started, if 2 January was Saturday Comment("first trading day in ", inp_Year, " year= ",first_day_New_Year);
Open the MT and take a look. Why ask such questions without looking? The bar is there with all the attributes of OHLC. Everything else is in your head.....
I just came across the fact that the quotes are there but trading is prohibited on futures contracts. That's why I thought it was the same situation.
https://www.mql5.com/ru/docs/objects/objectmove
How can I find out the number of the first trading day in January of any year using MQL4.5?
You can't. You can only collect such data yourself.
How can I find out the number of the first trading day in January of any year using MQL4.5?
Result
Result
Why decide it was a trading day? Is the idea in the presence of quotes? And if there were quotes but you couldn't trade - I think that's the question.
What made the decision that it was a trading day? Is the idea that there were quotes available? And if there were quotes but you couldn't trade - I think that's the question.
Open MT and take a look. Why ask such questions without looking? The bar is there with all the attributes of OHLC. Everything else is just your imagination.....
I noticed that trading days start in January in one of three variants: 2 January or 3 January or 4 January.
And I was even able to write a subroutine in MQL4 to determine the date of the first trading day in the new year.
int inp_Year=2016; //put the number of the year of interest into the variable
datetimefirst_day_New_Year=StringToTime(IntegerToString(inp_Year)+".01.02 00:00"); //variable where we will record the exact date of the beginning of the trading year, if the trading of a certain year started on the 2nd of January, if the 2nd of January was a weekday
if (TimeDayOfWeek(first_day_New_Year)==0) first_day_New_Year=StringToTime(StringSubstr(TimeToString(first_day_New_Year),0,4)+".01.03 00:00"); //3 January started trading of a certain year, if 2 January was Sunday
if (TimeDayOfWeek(first_day_New_Year)==6) first_day_New_Year=StringToTime(StringSubstr(TimeToString(first_day_New_Year),0,4)+"".01.04 00:00"); //4 January trades of a certain year started, if 2 January was Saturday
Comment("first trading day in ", inp_Year, " year= ",first_day_New_Year);
Open the MT and take a look. Why ask such questions without looking? The bar is there with all the attributes of OHLC. Everything else is in your head.....
I just came across the fact that the quotes are there but trading is prohibited on futures contracts. That's why I thought it was the same situation.