Skip to content

Commit

Permalink
Merge pull request #650 from nseam/dev
Browse files Browse the repository at this point in the history
Refs #337 New week detection
  • Loading branch information
kenorb authored Jun 26, 2022
2 parents 14c4309 + 3a77d0a commit b550609
Showing 1 changed file with 8 additions and 3 deletions.
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) {
// 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

0 comments on commit b550609

Please sign in to comment.