Questions from Beginners MQL5 MT5 MetaTrader 5 - page 606

 
pako:
There are four five weeks in a month, it's the fourth week of the month.
Yes, yes. What are the options?
 
new-rena:
I see. So he wants to account for weeks of this nature on the 29th of the previous month (Monday, for example) and up to the 31st of the current month (Monday too, for example). That would be more than a month. It is not logical to count such weeks.
No, I need to know what week it is from the beginning of the current month.
 
-Aleks-:
No, I need to know what week it is from the beginning of the current month.

Well, as another option - take bars from the chart on the period W1, count the number of bars of the required month + the required year and you will be happy.

Yes, yes! That's exactly it. But I don't know how to do it on 5p.

 
new-rena:

Well, as another option - take bars from the chart on the period W1, count the number of bars of the required month and you will be happy.

Yes, yes! That's exactly it. But I don't know how to do it on 5p.

How about without bars? Purely programmatically
 
pako:
How about without bars? Purely programmatically.
Well you can, of course, I wrote the simplest version.
 
pako:
How?

A little more complicated... And you probably need to subtract the number of days in the week from the lower number, multiplied by 7, and then compare it with the number of the month if the result is greater than 0 or 4. It's easier to take it from a chart.

int НомерНеделиВмесяце=NormalizeDouble(НомерДНЯвМесяце/7,0)+1;
 
pako:
There is no graph.
TimeLocal() only?
 
pako:
Yes

then what you tipped, I added there - multiply the week number by 7, analyse and it should work out.

This is for the first week when ==1. For the last one you have to subtract the extra days and do the same analysis.

It is still a mess, I think. It will work, but it is clumsy)))

 
pako:
didn't get it.
Better from a graphic, much easier. He's pulling a time-series there, isn't he?
 
pako:

there is no timetable

There's only time.

No problem. I've thrown in the algorithm. The beginning only without a timetable, that is:

int НомерДНЯвМесяце=TimeDay(TimeLocal());
Reason: