Skip to content
All library documents

Filtering Expert Advisor Ticks by Instrument Trading Sessions

Article MQL5 code base

Summary

This MQL5 library controls when an Expert Advisor processes incoming ticks. At startup it reads or constructs trading-session schedules for each day of the week, supporting up to ten sessions per day. The example creates a session-control object for the current symbol and returns early from the tick handler when the current server time falls outside a permitted session. It also shows how to supply schedules through inputs or load them directly from code.

Sessions may cross midnight when an end time is earlier than the start time, and a separate session object can be used for each instrument in a multicurrency program. The sample output illustrates session boundaries and closed-market messages, but does not provide trading-performance evidence. The implementation depends on the broker's session schedule and server-time conventions; users need to ensure the configured times match the instrument and account environment. The material explains execution gating, not a signal or strategy for choosing trades.

Key ideas

  • The library checks whether the current time falls within an instrument's configured trading sessions.
  • Schedules cover all days of the week and can contain multiple sessions per day.
  • Sessions can cross midnight when the end time precedes the start time.
  • Schedules can come from user inputs or be loaded from code, with separate instances for different instruments.
  • The example concerns tick processing and provides no evidence about trading performance.

Tags

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