Skip to content
All library documents

Adding Daily Trading Hours and Volume Limits to an Expert Advisor

Article MQL5 articles

Summary

This article describes adding a time-control layer to a MetaTrader 5 Expert Advisor. The proposed control defines a permitted operating interval for each day of the week, so the EA can restrict when it may open positions or submit orders. The schedule is stored through the platform’s input settings, which can be saved and loaded as configurations, rather than maintained in a separate schedule file.

The article distinguishes opening new exposure from managing existing orders: outside the allowed interval, the EA is still able to manage or close orders already held on the server. It outlines a class-based implementation that builds on an order-management class, stores daily start and end times, and checks user-entered time strings. It also notes that invalid times may be normalized by the platform and describes adding checks for malformed or out-of-range inputs. This is a programming walkthrough, not a trading-performance study. The schedule reduces opportunities for continuous trading, but the author stresses that it does not replace supervision or guarantee that the EA follows a trader’s broader policy.

Key ideas

  • A per-day schedule can limit when an EA is allowed to open positions or send orders.
  • Saved platform settings can provide reusable schedules without a separate configuration file.
  • The example permits management or closure of existing orders outside the entry window.
  • A control class can store daily start and end times and validate schedule inputs.
  • Time controls do not make an EA safe to leave unsupervised.

Tags

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