Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #337 New week detection #650

Merged
merged 1 commit into from
Jun 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions DateTime.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ class DateTime {
_result |= DATETIME_SECOND;
}

if (dt_curr.GetValue(DATETIME_DAY | DATETIME_WEEK) != dt_last.GetValue(DATETIME_DAY | DATETIME_WEEK)) {
// New week started.
_result |= DATETIME_WEEK;
if (dt_curr.GetValue(DATETIME_DAY | DATETIME_WEEK) == 0) {
kenorb marked this conversation as resolved.
Show resolved Hide resolved
// It's the first day of the week (Sunday).
// Note that GetValue() for the above flags just returns value of GetDayOfWeek().
// @see https://docs.mql4.com/dateandtime/dayofweek
if (dt_curr.GetValue(DATETIME_DAY | DATETIME_WEEK) != dt_last.GetValue(DATETIME_DAY | DATETIME_WEEK)) {
// New week started.
_result |= DATETIME_WEEK;
}
}

#ifdef __debug__
Expand Down