Time_H1onM1

Author: Yuriy Tokman
Time_H1onM1

This tool is designed for traders using the MetaTrader platform who want to clearly visualize specific time intervals on their charts. Its primary purpose is to automatically place visual markers at fixed hourly milestones, helping you identify the beginning of new trading hours at a glance.

How it Works

The script scans your current price chart and looks back over a specific number of previous candles (which you can customize in the settings). For every hour period it identifies within that range, the tool automatically draws a vertical line on your screen.

Key Features

  • Visual Clarity: Instead of manually trying to guess when an hour starts, the script places a dash-dotted vertical line exactly at the start of each H1 (one-hour) candle.
  • Customization: You can easily adjust the color of these lines through the settings menu to ensure they stand out clearly against your chosen chart background.
  • Efficiency: The tool is programmed to focus only on a specific amount of recent history (defaulting to 24 bars), ensuring that your chart remains clean and isn't cluttered with unnecessary lines from days or weeks ago.
  • Automatic Cleanup: The script includes a self-cleaning mechanism; when you remove the indicator from your chart, it automatically wipes those lines away so your workspace stays organized.

Summary for Traders

Think of this as an "automatic grid" for time. It takes the guesswork out of identifying hourly transitions, allowing you to see exactly where one hour ends and the next begins. This is particularly useful for traders who rely on specific times of day for entries, exits, or monitoring market volatility.

14 Views
0 Downloads
0 Favorites
Time_H1onM1
//+------------------------------------------------------------------+
//|                                                      Time_H1.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_chart_window
extern int       barsToProcess=24;
extern color     colir = Gray;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   int i;
  
  
  
   for (i=0;i<Bars;i++)
    {
    ObjectDelete("Line "+DoubleToStr(i,0));
    }   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted(),
//----
   limit,
   i=0; 
   if(counted_bars>0)
      counted_bars--;
   
   limit=Bars-counted_bars;
   
   if(limit>barsToProcess)
      limit=barsToProcess;

   while (i<limit)
   {           
      datetime t = iTime(NULL,PERIOD_H1,i);
      if (t>0)
       {
        ObjectCreate("Line "+DoubleToStr(i,0),OBJ_VLINE,0,t,0);
        ObjectSet("Line "+DoubleToStr(i,0),OBJPROP_STYLE,STYLE_DASHDOTDOT);
        ObjectSet("Line "+DoubleToStr(i,0),OBJPROP_COLOR,colir);
        ObjectSet("Line "+DoubleToStr(i,0),OBJPROP_TIMEFRAMES,OBJ_PERIOD_M1);
       }            
     i++;  
   }  
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments