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
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:
you can, as you suggest, count each bar and find out if there was a weekend between the current and the previous bar.... in general here only the possibility of complicating the task is limited by desire ))))
We should start by assuming that time intervals start and end at 0:0.
We have to start by assuming that the time intervals start and end at 0:0.
in my example this assumption is not needed, but we need to assume that the calculation is within one calendar year
there was a solution in the first post, alternatively there should be another solution in the topic Only useful codes from kimiw, I think I have seen
in my example this assumption is not needed, but we need to assume that the calculation is within one calendar year
in the first post was the solution, as an option - there should be another solution in the thread Only useful codes from KimIV, I think I saw
It is not just days that need to be counted, but working days or weekends.
It is not just days that need to be counted, but weekdays or weekends.
It's hard to say, the wording of the problem is ambiguous:
how do you know how many weekends there were between points, e.g. on D1, and then add them to the required bars?
It's hard to say, the wording of the problem is ambiguous:
...Where is the ambiguity: "how do you find out how many outputs there were between points on e.g. D1 to add them to the required bars? "
Why this is needed is another question.
Seems to have checked, seems fine. Check if you're not too lazy.
Where is the ambiguity: " how do you know how many outputs there were between points on e.g. D1 so you can add them to the bars you want? "
Why would that be necessary is another question.
I think that if we chat for a couple more hours, we will start to evaluate the problem, and how many outputs can be between two bars.... and surely there is always a correspondence that before Monday comes Sunday?
)))))
with correcting the calculation of days by subtracting the datetime , I think this code will work for all cases
By date
To the first point I add bars
Then count the number of bars between these dates.
You get less than the number of bars you set. The difference between the number of bars you set and the number of bars you get is the number of days off. Thus, we obtain the number of bars of any period, even of a minute period. Just carefully check how many bars are returned by this function. Either the two outer bars or one of them will be considered. I do not remember exactly, but it seems both of them are considered.Then count the number of bars between these dates.
You get less than the given number of bars. The difference between the given number of bars and the received number of bars is the number of days off. Thus, we obtain the number of bars of any period, even of a minute period. Just carefully check how many bars are returned by this function. Either the two outer bars or one of them will be considered. I do not remember exactly, but it seems both of them are considered.Talk about the dates for which there are no bars yet.
just in case, I'll add an example - it counts how many bars are missing