Skip to content
All library documents

Counting Trading Time Across a Weekly Market Closure

Article MQL5 code base

Summary

The document outlines time utilities for handling weekly market schedules. It describes functions that identify Sunday and Friday boundary times, count Sundays or hourly candles between dates, and add a requested number of trading seconds to a timestamp. The central example applies this idea to a position that should close after five trading hours: an opening on Friday evening maps to a close early Monday, skipping the weekend closure.

This is useful for time-based exits, expiry calculations, and historical bar counting when elapsed calendar time differs from active trading time. The note does not define the market calendar in detail, explain holiday handling despite its introduction, or show how daylight-saving changes, partial sessions, or exchange-specific schedules are treated. Its example conveys the intended weekend behavior, but users would need to verify the implementation against the instrument’s actual trading hours before relying on it for live order timing or backtests.

Key ideas

  • Trading-time calculations can skip closed periods instead of adding ordinary elapsed time.
  • A helper can add a specified number of trading seconds to an opening timestamp.
  • The example moves a Friday position’s five-hour exit into Monday because weekend hours are excluded.
  • The document also lists helpers for week boundaries and counts of Sundays or hourly candles.
  • Holiday, daylight-saving, and instrument-specific session behavior are not explained.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.