Author: Copyright � 2005, MetaQuotes Software Corp.
time1_v2

This script is designed as a visual aid for traders using the MetaTrader platform. Its primary purpose is to automatically place vertical markers on your trading chart at specific times of the day, allowing you to easily identify key sessions or time-based milestones without having to manually draw them.

How it Works

When you apply this script to a chart, it performs two main actions:

1. Historical Mapping The tool automatically scans through your existing price history. It looks back at all the past candles on your current chart and identifies specific times. Whenever it finds a match for the programmed times, it draws a vertical line across the screen at that exact point in history.

2. Real-Time Monitoring In addition to looking at the past, the script constantly monitors the current time as it ticks forward. As soon as the clock reaches one of the predefined target times, the script will automatically place a new vertical line on your live chart.

Visual Organization

To help you distinguish between different times at a glance, the script uses a color-coded system. Each specific time of day is assigned a unique color:

  • 08:00: Marked with an Aqua line.
  • 11:00: Marked with a Blue line.
  • 12:30: Marked with a Purple line.
  • 14:00: Marked with an Orange line.
  • 17:00: Marked with a Brown line.

Summary for the User

Instead of having to keep track of the clock or manually mark your charts during the trading day, this tool automates that process for you. It provides a clean, visual timeline that remains consistent across your historical data and your live trading sessions, helping you stay organized and aware of important time boundaries.

Price Data Components
Series array that contains open time of each bar
12 Views
0 Downloads
0 Favorites
time1_v2
//+------------------------------------------------------------------+
//|                                                        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