TimeLib by BabyBear - MetaTrader 4 Library - MT4/MT5 Resources
Several functions of holiday work:
Function
Date and time started last Monday ( date and time dt);
Returns the last Sunday before 22:00 dt.
Date and time end next Friday ( date and time dt);
Returns the nearest Friday 23:00 time after dt.
Function
integer Sunday midnight count ( datetime start, datetime end);Returns the number of holidays between two dates.
Function
Integer hour candle count ( datetime start, datetime end);Returns the number of trading hours between two dates. In other words, it is the number of candles per hour between "start" and "end".
Function
Add transaction seconds to date and time (start of date and time , integer seconds);
Add transaction time to date.
Example: The position needs to be closed 5 trading hours after it is opened. If the position is opened at 21:00 on Friday, it should be closed at 2:00 on Monday. The initial time is calculated as follows:
Add trading seconds( order opening time (), 5 * 60 * 60 );
Attachment download
📎DateTime.mqh (3.28 KB)
📎 _WeekEnd.mq4 (1.51 KB)
Source: MQL5 #7080
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •