Counting bars including weekends - page 2

 
forex2030:

I don't understand what this will do for me?

Maybe some sort of day to point enumeration and if in the period day = 6 or 0 then day++;

There is no point. All charting in the market (of any kind) is done on the basis that there are simply no days off.

 
Алексей Тарабанов:

There is no point. All charting in the market (any market) is done on the basis that there are simply no days off.

It is possible to cycle through the days, e.g. if the last date is 15 and then the date 18 is known, then we will remember +2 (i.e. 16 and 17 days off).

 
forex2030:

It is possible to cycle through the days, e.g. if the last date is 15 and then the date 18 is known, then remember +2 (i.e. weekends 16 and 17)

You can if you really want to. There is no point.

The trend will continue on the 18th. From 15 to 18 is one bar.

 
Алексей Тарабанов:

You can if you really want to. There is no point.

How is it pointless?
I will add this value to my bars and get 12+4=16 bars and the line will stand on the right date in the end

 
forex2030:

What do you mean there is no point?
I will add this value to my bars and get 12+4=16 bars and the line will stand on the desired date in the end

The line hangs in the air.

 
Алексей Тарабанов:

The line will hang in the air.

If I add 16 bars to the first point instead of 12 bars, why will it hang in the air?

 
forex2030:

If I add 16 bars to the first point instead of 12 bars, why would it hang in the air?

Good night.

 

I need something like this, but properly framed, it's just a thought

int NumData(datetime data1,datetime data2){
    int num=0;
    for (int d=data1; d>=data2; d--)
    if(TimeDayOfWeek(d)==6 || TimeDayOfWeek(d)==0) num++;
return(num);}
 
Why not take this problem and solve it? The start and end dates are known, we can count the total number of days between them. Then count the total number of whole weeks. Each week has five working days and two days off - that's easy. Troubles with the remainder (we'll assume that it is in the beginning), depending on the first day of the week and its duration, the remainder may or may not take the weekend. We would have to write a switch for seven options for each day of the week and perform seven calculations depending on the day of the week of the beginning and the duration of the remainder. Then look at this switch and maybe you can see how these calculations can be generalized and simplified. The point is that something has to be done.
 
Dmitry Fedoseev:
And why not solve this problem? Start and end dates are known, we can calculate the total number of days between them. Then count the total number of whole weeks. Each week has five working days and two days off - that's easy. Troubles with the remainder (we'll assume that it is in the beginning), depending on the first day of the week and its duration, the remainder may or may not take the weekend. We would have to write a switch for seven options for each day of the week and perform seven calculations depending on the day of the week of the beginning and the duration of the remainder. Then look at this switch and maybe you can see how these calculations can be generalized and simplified. The point is that something has to be done.

complicated, there is a time between dates in seconds (datetime) - this is enough to calculate the number of whole days in which 24 hours, 60 minutes in each hour and 60 seconds in a minute.... google to help

If we're talking about a twisted way of counting, you can do it this way:

input datetime d_start = D'2020.01.01';
input datetime d_stop  = D'2020.02.01';
//+------------------------------------------------------------------+
void OnStart()
{
   MqlDateTime dts[2];
   TimeToStruct(d_start,dts[0]);
   TimeToStruct(d_stop,dts[1]);
   printf("Между датами %i дней",dts[1].day_of_year - dts[0].day_of_year);
}
//+------------------------------------------------------------------+

it is possible as you suggest, to count each bar and find out were there any days off between the current and previous bar.... in general here only the wish is limited by the possibility to complicate the task ))))