Author: Copyright � 2005, MetaQuotes Software Corp.
time1

This script is an automated visual tool designed for the MetaTrader trading platform to help traders identify key market sessions or specific time intervals on their charts. Rather than requiring a user to manually draw lines at every recurring hour, the script automatically scans historical data and real-time price action to place vertical markers exactly where specified times occur.

How it Works

The logic operates by scanning the timeline of your trading chart and looking for specific "matches" based on the clock time. When the script detects a match between the current bar's time and a pre-defined schedule, it draws a permanent vertical line (a visual boundary) to separate different periods of the day.

Scheduled Markers

The script is programmed to identify and highlight five distinct time slots throughout the trading day, each represented by a unique color for easy identification:

  • 08:00 AM: Marked with an Aqua line.
  • 11:00 AM: Marked with a Blue line.
  • 12:30 PM: Marked with a Purple line.
  • 02:00 PM (14:00): Marked with an Orange line.
  • 05:00 PM (17:00): Marked with a Brown line.

Key Features

  • Historical Mapping: Upon loading, the script automatically looks back through your existing chart history and places these markers on all previous days where those specific times occurred.
  • Real-Time Updates: The script continues to monitor the live market. As new minutes pass and reach the designated target times, it will automatically generate the corresponding colored line on the live candle.
  • Visual Organization: By using different colors for different hours, the tool allows traders to instantly recognize which "zone" or session they are currently trading in without having to constantly check the system clock.
Price Data Components
Series array that contains open time of each bar
11 Views
0 Downloads
0 Favorites
time1
//+------------------------------------------------------------------+
//|                                                        time1.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
string t;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
int i;
     i=Bars-1;
     while(i>0)
      {
      t=DoubleToStr(i,0);
      if(TimeMinute(Time[i])==0&&TimeHour(Time[i])==8)
         {
         ObjectCreate(t, OBJ_VLINE, 0, Time[i],0);
         ObjectSet(t, OBJPROP_COLOR,Aqua);
         }
      if(TimeMinute(Time[i])==0&&TimeHour(Time[i])==11)
         {
         ObjectCreate(t, OBJ_VLINE, 0, Time[i],0);
         ObjectSet(t, OBJPROP_COLOR,Blue);
         }
      if(TimeMinute(Time[i])==30&&TimeHour(Time[i])==12)
         {
         ObjectCreate(t, OBJ_VLINE, 0, Time[i], 0);
         ObjectSet(t, OBJPROP_COLOR,Purple);
         }
      if(TimeMinute(Time[i])==0&&TimeHour(Time[i])==14)
         {
         ObjectCreate(t, OBJ_VLINE, 0, Time[i],0);
         ObjectSet(t, OBJPROP_COLOR,Orange);
         }
      if(TimeMinute(Time[i])==0&&TimeHour(Time[i])==17)
         {
         ObjectCreate(t, OBJ_VLINE, 0, Time[i],0);
         ObjectSet(t, OBJPROP_COLOR,Brown);
         }
      i--;
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//---- 
      t=TimeToStr(CurTime());
      if(TimeMinute(CurTime())==0&&TimeHour(CurTime())==8)
         {
         ObjectCreate(t, OBJ_VLINE, 0, CurTime(),0);
         ObjectSet(t, OBJPROP_COLOR,Aqua);
         }
      if(TimeMinute(CurTime())==0&&TimeHour(CurTime())==11)
         {
         ObjectCreate(t, OBJ_VLINE, 0,CurTime(),0);
         ObjectSet(t, OBJPROP_COLOR,Blue);
         }
      if(TimeMinute(CurTime())==30&&TimeHour(CurTime())==12)
         {
         ObjectCreate(t, OBJ_VLINE, 0,CurTime(), 0);
         ObjectSet(t, OBJPROP_COLOR,Purple);
         }
      if(TimeMinute(CurTime())==0&&TimeHour(CurTime())==14)
         {
         ObjectCreate(t, OBJ_VLINE, 0,CurTime(),0);
         ObjectSet(t, OBJPROP_COLOR,Orange);
         }
      if(TimeMinute(CurTime())==0&&TimeHour(CurTime())==17)
         {
         ObjectCreate(t, OBJ_VLINE, 0,CurTime(),0);
         ObjectSet(t, OBJPROP_COLOR,Brown);
         }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments