3FoldTradingHours_v1

Download script
Author: cubesteak
3FoldTradingHours_v1

This tool is designed to act as a visual time-management monitor for traders using the MetaTrader platform. Its primary purpose is to clearly communicate whether the current market time falls within your preferred trading windows or outside of them, helping you maintain discipline regarding when you should be active in the markets.

Core Functionality

The script allows you to define up to three distinct sets of "Trading Hours." By inputting specific start and end hours for each of these three periods, you create a customized schedule tailored to your specific strategy—for example, you could set one window for the London session, one for the New York session, and another for a specific high-volatility period.

How It Works

The logic follows a straightforward verification process:

  • Configuration Check: When you first load the tool, it checks if you have entered any time parameters. If all fields are left empty, the tool will notify you on your chart that no trading hours have been set yet.
  • Real-Time Monitoring: The script constantly monitors the current hour of the day. It compares the "live" time against the three different windows you have provided.
  • Active Zone Detection: If the current time falls within any of your three defined windows, the tool recognizes this as an active period.
  • Visual Feedback: The script provides a real-time visual notification directly on your trading chart:
    • Trading Hours: When the current time matches one of your programmed windows, a notification will appear on the screen highlighting that it is currently a valid time to trade.
    • Non-Trading Hours: If the current time falls outside of all three periods you defined, the tool will display a prominent warning message. This serves as a visual barrier to remind you to stay out of the market during "off-limits" times.

Key Benefits for Traders

Instead of constantly checking your clock or manually calculating time zones, this script automates that oversight. It provides an immediate, at-a-glance confirmation of your trading schedule, helping to reduce emotional trading during low-liquidity periods or ensuring you don't miss out on the specific sessions you find most profitable.

6 Views
0 Downloads
0 Favorites
3FoldTradingHours_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                            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