Market Sessions
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GreatestUsername

//@version=5
indicator("Market Sessions", overlay=true, max_lines_count = 500)

marketOpenHour = input.int(13)
marketOpenMinutes = input.int(00)
marketCloseHour = input.int(22)
marketCloseMinute = input.int(00)

openColor = input.color(color.green)
closeColor = input.color(color.red)

targetOpen = timestamp("UTC", year, month, dayofmonth, marketOpenHour, marketOpenMinutes)
targetClose = timestamp("UTC", year, month, dayofmonth, marketCloseHour, marketCloseMinute)
marketOpen = false
marketClose = false
if dayofweek != dayofweek.saturday and dayofweek != dayofweek.sunday
    marketOpen := targetOpen == time
    marketClose := targetClose == time

if marketOpen or marketClose
    line.new(bar_index, 0, bar_index, 0, color=marketOpen ? openColor : closeColor, extend=extend.both)