I decided to publish this class after reading this publication. This topic looks interesting. My approach does not solve every problem as well. Therefore, suggest what can be improved.
The class usage example was made similar to this variant. That way it is easier to see the advantages and disadvantages.
The advantages:

Options for setting the time
1. Daily session. For example, it allows the trading every day in the specified time interval. Conditions:
2. Night session. For example, the trading through the night is allowed: start today, end tomorrow. And so every day. Conditions:
3. Within the range of dates. For example, the trading is allowed from the session start date up to the session end date. Conditions:
4. Out of the range of dates. The session start date is greater than the session end date. Thus, the trading is allowed until the session end date and after the new session start date. Conditions:
5. Disabling/enabling the trading on a week day. It is sufficient to set "true" in the parameters for each of the week days, if you want to trade. Or "false" to disable trading.
6. All the setting can be changed anywhere in program using the Init() methods.
P.S. The class was created for the MetaTrader 5, but it also works for the MetaTrader 4. The only difference is that the MetaTrader 4 strategy tester does not support the optimization of the time intervals in the datеtime format. But it is solved by replacing the datеtime to long in the EA input parameters.
Translated from Russian by MetaQuotes Ltd.
Original code: /ru/code/14305
VWAP Lite - Volume Weighted Average Price
VWAP is an intra-day calculation used primarily by algorithms and institutional traders to assess where a stock is trading relative to its volume weighted average for the day.
ManualTradeOnStrategyTester
A simple way on how EA can link a manual order command from outside to use it in MetaTrader 5 Strategy Tester.
Sentiment
Robot that trades the open sentiment of the market.
TradeState - the EA trading mode switcher depending on the time
The class restricts the EA trading by time. It has flexible configuration options, which allow to set a custom number of the time zones, and also to allow trading only on the specified week days.