Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

TimeInRange Time Check Function - Library for MetaTrader 4 - MT4/MT5 Resources

author EAcpu | 7 reads | 0 comments |

Quick time range checking function. Does not use slow string parsing.

If the time is within the range, the function returns TRUE, otherwise it returns FALSE.

Drag and drop the .mq4 file into the MQL4\Libraries\ folder.

Add this line to your EA:

 #include "..\libraries\time_in_range.mq4"
There are three versions of this function:

1. With separated hours and minutes input. Example:
 if (timerange( timecurrent (), 23 , 00 , 02 , 15 )) { /* trade*/ } // Check if the current time is within the range of 23:00-02:15

2. Enter the decimal number. example:


Attachment download

📎 time_in_range.mq4 (3.22 KB)

Source: MQL5 #16398

Verification code Refresh