//@version=6 // Macro Times — every hour from xx:42 to xx+1:15, from 02:42 through 16:15 (UTC-4) // Each window has its own checkbox so you can show only the hours you care about. indicator("Macro Times", overlay = false, format = format.price) // ==== SETTINGS ==== tz = "Etc/GMT+4" // fixed UTC-4 w = input.int(3, "Line width", minval = 1, maxval = 10, group = "Style") col_normal = input.color(color.black, "Normal window", group = "Style") col_lunch = input.color(color.orange, "Lunch window", group = "Style") lunchFrom = input.int(11, "Lunch colour from hour", minval = 0, maxval = 23, group = "Style", inline = "lu") lunchTo = input.int(12, "to", minval = 0, maxval = 23, group = "Style", inline = "lu", tooltip = "Windows whose START hour falls in this range get the lunch colour. Default 11 and 12, i.e. 11:42-12:15 and 12:42-13:15.") // ==== WINDOWS ==== // Each line runs from HH:42 to (HH+1):15. g = "Windows (xx:42 → xx+1:15)" s02 = input.bool(false, "02:42 – 03:15", group = g) s03 = input.bool(false, "03:42 – 04:15", group = g) s04 = input.bool(false, "04:42 – 05:15", group = g) s05 = input.bool(false, "05:42 – 06:15", group = g) s06 = input.bool(false, "06:42 – 07:15", group = g) s07 = input.bool(false, "07:42 – 08:15", group = g) s08 = input.bool(false, "08:42 – 09:15", group = g) s09 = input.bool(true, "09:42 – 10:15", group = g) s10 = input.bool(true, "10:42 – 11:15", group = g) s11 = input.bool(true, "11:42 – 12:15", group = g) s12 = input.bool(true, "12:42 – 13:15", group = g) s13 = input.bool(true, "13:42 – 14:15", group = g) s14 = input.bool(true, "14:42 – 15:15", group = g) s15 = input.bool(false, "15:42 – 16:15", group = g) hours = array.from(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) enabled = array.from(s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15) // ==== DRAW (today only) ==== var array lines = array.new() if barstate.islast // wipe the previous set so nothing is drawn twice for i = 0 to array.size(lines) - 1 line.delete(array.get(lines, i)) array.clear(lines) int y = year(time, tz) int mo = month(time, tz) int d = dayofmonth(time, tz) for i = 0 to array.size(hours) - 1 if array.get(enabled, i) int h = array.get(hours, i) int t1 = timestamp(tz, y, mo, d, h, 42, 0) int t2 = timestamp(tz, y, mo, d, h + 1, 15, 0) color c = (h >= lunchFrom and h <= lunchTo) ? col_lunch : col_normal array.push(lines, line.new(t1, 0, t2, 0, xloc = xloc.bar_time, extend = extend.none, color = c, width = w))