Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 4 Indicator | Vertical Time Lines

  • Indicator can draws up to six different vertical lines each at a designated time.
  • Each vertical line can be historically repeated.
  • Time format: hh:mm.
  • The default historical days Input is 50. Increase as required. Aging equipment may suffer performance at too high a number. 

Possible use:

  1. Mark session open or close time.
  2. Mark time of regular news release.
  3. Mark any other relevant time.

Note - Answer to a question:

  • A Vertical Time Line set at 09:30 on a timeframe of M30 or lesser will read as 09:30 because each timeframe will have a a candle that opens/starts at 09:30.
  • A Vertical Time Line set at 09:30 on a timeframes of H1 or greater will not read as 09:30 because each timeframe will not have a candle that opens/starts at 09:30. ie. A Vertical Time Line set at 09:30 on a H1 timeframe will read as 09:00 because 09:30 is within the 09:00 - 10:00 candle and the candle open/start time is 09:00.

MetaTrader Experts, Indicators, Scripts and Libraries

The present code accommodate up to six vertical lines. To code in more lines repeat the relevant blocks of code and rename where applicable.

Default Inputs Code

  • Edit the below code to permanently change default inputs.
  • Edit the following as required: Line_x_Color (DodgerBlue, etc), Line_x_Visible (true or false), Line_x_Time (08:30 etc), Line_x_Width (1, 2, 3, 4 or 5), Line_x_Style (0=solid, 1=dash, 2=dotted, 3=dash & dot, 4=double dotted dash & dot).
  • An idea of basic editing can be got here - https://www.mql5.com/en/code/11087
  • MQL4 color name and reference here - https://docs.mql4.com/constants/objectconstants/webcolors
// DEFAULT INPUTS : START
//-----------------------------------------------------
input int Historical_Days = 50; // Historical days
  
input color  Line_1_Color = DodgerBlue; // Line 1  Color 
input bool   Line_1_Visible = true;     // Line 1  Visible
input string Line_1_Time = "08:00";     // Line 1  Time
input LW     Line_1_Width = 1;          // Line 1  Width
input ENUM_LINE_STYLE Line_1_Style = 2; // Line 1  Style

input color  Line_2_Color = DodgerBlue; // Line 2  Color
input bool   Line_2_Visible = true;     // Line 2  Visible
input string Line_2_Time = "09:00";     // Line 2  Time 
input LW     Line_2_Width = 1;          // Line 2  Width
input ENUM_LINE_STYLE Line_2_Style = 2; // Line 2  Style

input color  Line_3_Color = Magenta;    // Line 3  Color
input bool   Line_3_Visible = false;    // Line 3  Visible
input string Line_3_Time = "10:00";     // Line 3  Time
input LW     Line_3_Width = 1;          // Line 3  Width
input ENUM_LINE_STYLE Line_3_Style = 2; // Line 3  Style

input color  Line_4_Color = Magenta;    // Line 4  Color
input bool   Line_4_Visible = false;    // Line 4  Visible
input string Line_4_Time = "11:00";     // Line 4  Time
input LW     Line_4_Width = 1;          // Line 4  Width
input ENUM_LINE_STYLE Line_4_Style = 2; // Line 4  Style

input color  Line_5_Color = DarkOrange; // Line 5  Color
input bool   Line_5_Visible = false;    // Line 5  Visible
input string Line_5_Time = "12:00";     // Line 5  Time
input LW     Line_5_Width = 1;          // Line 5  Width
input ENUM_LINE_STYLE Line_5_Style = 2; // Line 5  Style

input color  Line_6_Color = DarkOrange; // Line 6  Color
input bool   Line_6_Visible = false;    // Line 6  Visible 
input string Line_6_Time = "13:00";     // Line 6  Time
input LW     Line_6_Width = 1;          // Line 6  Width
input ENUM_LINE_STYLE Line_6_Style = 2; // Line 6  Style  
//----------------------------------------------------- 
// DEFAULT INPUTS : END 
12266

Best MetaTrader Indicators + Profitable Expert Advisors