3FoldTradingHours

Download script
Author: cubesteak
3FoldTradingHours

This tool is designed to serve as a visual time-management guide for traders using the MetaTrader platform. Its primary purpose is to monitor the current time and provide an immediate on-screen status update regarding whether the market is currently within your predefined active trading windows.

Core Functionality

The script allows you to establish up to three distinct "Trading Windows" throughout a 24-hour day. By inputting specific start and end hours for each window, you create a customized schedule that dictates when you consider the market suitable for activity.

How it Works

The logic operates through a continuous monitoring process:

  • Configuration: You define three separate sets of start and end hours. If no hours are entered, the system alerts you that the trading hours have not been set.
  • Real-Time Monitoring: The script constantly checks the current hour of the day against your three defined windows.
  • Active Status Check: It evaluates if the current time falls inside any of the three designated periods.
  • Visual Feedback: The tool provides a clear, text-based notification directly on your trading chart:
    • If the current time falls within any of your specified windows, it displays a "TRADING HOURS" alert.
    • If the current time falls outside of all three windows, it displays a "NON-TRADING HOURS" warning.

Key Benefits

This script acts as a constant "traffic light" for your trading session. Instead of manually checking the clock to ensure you are trading during high-liquidity periods or avoiding specific times (like news events or low-volume sessions), this tool provides an instant visual confirmation, helping you maintain discipline and focus on your preferred trading schedule.

6 Views
0 Downloads
0 Favorites
3FoldTradingHours
//+------------------------------------------------------------------+
//|                                            3FoldTradingHours.mq4 |
//|                                                        cubesteak |
//|                                         http://www.cubesteak.net |
//+------------------------------------------------------------------+
#property copyright "cubesteak"
#property link      "http://www.cubesteak.net"

#property indicator_chart_window     

//---- input parameters
extern int       FromHourTrade1=-1;
extern int       ToHourTrade1=-1;
extern int       FromHourTrade2=-1;
extern int       ToHourTrade2=-1;
extern int       FromHourTrade3=-1;
extern int       ToHourTrade3=-1;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
//----
   
int a,b,c;
bool UseHourTrade = true;

if (UseHourTrade)
{

   if (
         FromHourTrade1==-1 &&
         ToHourTrade1==-1 &&
         FromHourTrade2==-1 &&
         ToHourTrade2==-1 &&
         FromHourTrade3==-1 &&
         ToHourTrade3==-1 
      ) Comment("Trading Hours Not Set");
      else
      {

      int now = Hour();
      if (

            ( (now>=FromHourTrade1) ) &&
            ( (now<=ToHourTrade1) )
         
         ) a=1;

   
      if (

            ( (now>=FromHourTrade2) ) &&
            ( (now<=ToHourTrade2) )
         
         ) b=1;


      if (

            ( (now>=FromHourTrade3) ) &&
            ( (now<=ToHourTrade3) )
         
         ) c=1;

      if (
            (a!=1) &&
            (b!=1) &&
            (c!=1)
         )
      {
      Comment(
      "\n"," ^^^^^^^^^^^^^^^^^^^^",
      "\n","   * NON-TRADING HOURS * ",
      "\n"," ^^^^^^^^^^^^^^^^^^^^");
      }
      else    Comment(
      "\n"," ^^^^^^^^^^^^^^^^",
      "\n","   * TRADING HOURS * ",
      "\n"," ^^^^^^^^^^^^^^^^");
      }
}

   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments