Shade COVID Period
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheOmegaTrader
//@version=4

study("Shade COVID Period",overlay=true)
fromHour = input(7)
toHour = input(10)
weekdaysOnly = input(true)
useVline = input(false)
dayIsOk = not weekdaysOnly or (dayofweek != dayofweek.saturday and dayofweek != dayofweek.sunday)
FromYear = input(title="From Year", type=input.integer, defval=2019, minval=1800)
FromMonth = input(title="From Month", type=input.integer, defval=09, minval=1, maxval=12)
FromDay = input(title="From Day", type=input.integer, defval=03, minval=1, maxval=31)
ToYear = input(title="To Year", type=input.integer, defval=2020, minval=1800)
ToMonth = input(title="To Month", type=input.integer, defval=03, minval=1, maxval=12)
ToDay = input(title="To Day", type=input.integer, defval=31, minval=1, maxval=31)
t1 = timestamp( FromYear, FromMonth,FromDay, fromHour, 00, 00)
t2 = timestamp( ToYear, ToMonth, ToDay, toHour, 00, 00)
ShadeColour = input(title="Color", type=input.color, defval=color.silver)
timeIsOk = (time >= t1) and (time <= t2)
bgcolor( not useVline and timeIsOk and dayIsOk ? ShadeColour : color.rgb(0, 0, 0, transp = 75))//modified this due to: https://quantnomad.com/faq-the-transp-argument-will-be-deprecated-soon-how-to-fix-it/
if useVline and timeIsOk and dayIsOk
    line.new(bar_index, low * .9999, bar_index, high * 1.0001, xloc.bar_index, extend.both, #FF8000ff, line.style_solid, 1)