ICT Time Indicator - Minimalistic
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SuspiciousAvocado

//@version=5
indicator(title = 'ICT Time Indicator - Minimalistic', shorttitle = 'ICT Time Indicator')

// Constants
ny_timezone = string('America/New_York')


// Inputs
group_time = 'Time Settings (New York Time):'
title_am = "Morning Session"
title_lunch = "Lunch"
title_pm = "Afternoon Session"
title_marco_0950_1010 = "Marco 0950-1010"
title_marco_1050_1110 = "Marco 1050-1110"
title_marco_1450_1510 = "Marco 1450-1510"
title_silver_bullet_london = "Silver Bullet London Open"
title_silver_bullet_7_830 = "Silver Bullet 7-8:30 NY"
title_silver_bullet_am = "Silver Bullet AM"
title_silver_bullet_pm = "Silver Bullet PM"
title_silver_bullet_final_hour = "Silver Bullet Final Hour"

bool_show_am = input.bool(defval=false, title='', inline='s1', group=group_time)
session_am = input.session(defval='0830-1201', title=title_am, inline='s1', group=group_time)

bool_show_lunch = input.bool(defval=false, title='', inline='s2', group=group_time)
session_lunch = input.session(defval='1201-1301', title=title_lunch, inline='s2', group=group_time)

bool_show_pm = input.bool(defval=false, title='', inline='s3', group=group_time)
session_pm = input.session(defval='1301-1631', title=title_pm, inline='s3', group=group_time)

bool_show_marco_0950_1010 = input.bool(defval=true, title='', inline='s4', group=group_time)
session_marco_0950_1010 = input.session(defval='0950-1011', title=title_marco_0950_1010, inline='s4', group=group_time)

bool_show_marco_1050_1110 = input.bool(defval=true, title='', inline='s5', group=group_time)
session_marco_1050_1110 = input.session(defval='1050-1111', title=title_marco_1050_1110, inline='s5', group=group_time)

bool_show_marco_1450_1510 = input.bool(defval=true, title='', inline='s6', group=group_time)
session_marco_1450_1510 = input.session(defval='1450-1511', title=title_marco_1450_1510, inline='s6', group=group_time)

bool_show_silver_bullet_london = input.bool(defval=true, title='', inline='s7', group=group_time)
session_silver_bullet_london = input.session(defval='0300-0401', title=title_silver_bullet_london, inline='s7', group=group_time)

bool_show_silver_bullet_7_830 = input.bool(defval=false, title='', inline='s8', group=group_time)
session_silver_bullet_7_830 = input.session(defval='0700-0831', title=title_silver_bullet_7_830, inline='s8', group=group_time)

bool_show_silver_bullet_am = input.bool(defval=true, title='', inline='s9', group=group_time)
session_silver_bullet_am = input.session(defval='1000-1101', title=title_silver_bullet_am, inline='s9', group=group_time)

bool_show_silver_bullet_pm = input.bool(defval=true, title='', inline='s10', group=group_time)
session_silver_bullet_pm = input.session(defval='1400-1501', title=title_silver_bullet_pm, inline='s10', group=group_time)

bool_show_silver_bullet_final_hour = input.bool(defval=false, title='', inline='s11', group=group_time)
session_silver_bullet_final_hour = input.session(defval='1500-1601', title=title_silver_bullet_final_hour, inline='s11', group=group_time)


group_bar = 'Visual Settings:'
color_session = input.color(#2a2e39, title='Session', group = group_bar)
color_lunch = input.color(#ffffff00, title='Lunch', group = group_bar)
color_marco = input.color(#787b86, title='Marco', group = group_bar)
color_silver_bullet = input.color(#b2b5be, title='Silver Bullet', group = group_bar)
int_line_width = input.int(1, title='Thickness', group = group_bar)



// Calculations
time_am = time(timeframe = timeframe.period, session = session_am, timezone = ny_timezone)
time_lunch = time(timeframe = timeframe.period, session = session_lunch, timezone = ny_timezone)
time_pm = time(timeframe = timeframe.period, session = session_pm, timezone = ny_timezone)
time_marco_0950_1010 = time(timeframe = timeframe.period, session = session_marco_0950_1010, timezone = ny_timezone)
time_marco_1050_1010 = time(timeframe = timeframe.period, session = session_marco_1450_1510, timezone = ny_timezone)
time_marco_1450_1510 = time(timeframe = timeframe.period, session = session_marco_1450_1510, timezone = ny_timezone)
time_silver_bullet_london = time(timeframe = timeframe.period, session = session_silver_bullet_london, timezone = ny_timezone)
time_silver_bullet_7_830 = time(timeframe = timeframe.period, session = session_silver_bullet_7_830, timezone = ny_timezone)
time_silver_bullet_am = time(timeframe = timeframe.period, session = session_silver_bullet_am, timezone = ny_timezone)
time_silver_bullet_pm = time(timeframe = timeframe.period, session = session_silver_bullet_pm, timezone = ny_timezone)
time_silver_bullet_final_hour = time(timeframe = timeframe.period, session = session_silver_bullet_final_hour, timezone = ny_timezone)

var line_color = color(#ffffff00)

if ((time_marco_0950_1010 and bool_show_marco_0950_1010)
 or (time_marco_1050_1010 and bool_show_marco_1050_1110) 
 or (time_marco_1450_1510 and bool_show_marco_1450_1510))
    line_color := color_marco

else if ((time_silver_bullet_london and bool_show_silver_bullet_london)
 or (time_silver_bullet_7_830 and bool_show_silver_bullet_7_830)
 or (time_silver_bullet_am and bool_show_silver_bullet_am)
 or (time_silver_bullet_pm and bool_show_silver_bullet_pm))
 or (time_silver_bullet_final_hour and bool_show_silver_bullet_final_hour)
    line_color := color_silver_bullet

else if ((time_am and bool_show_am)
 or (time_pm and bool_show_pm))
    line_color := color_session

else if (time_lunch and bool_show_lunch)
    line_color := color_lunch
else
    line_color := color(#ffffff00)


// Plots
plot_condition = na(time_am) or na(time_lunch) or na(time_pm) or na(time_marco_0950_1010) or na(time_marco_1050_1010) or na(time_marco_1450_1510) or na(time_silver_bullet_london) or na(time_silver_bullet_am) or na(time_silver_bullet_pm)
plot(plot_condition ? 0:na, style=plot.style_columns, linewidth = int_line_width, histbase = int_line_width, color=line_color, title='Plot')