Days and Session
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mbome237

//@version=5
indicator(title="Days and Session", overlay=true)
// ——————————————————————————— \\
// ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ \\

// ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ \\
// ——————————————————————————— \\


separateDays    = input.bool(true, title="Show New Session Candle")
colorDays       = input.bool(true, title="Color Day's Background")  

color lundi     = input.color(color.yellow, "Monday")
color mardi     = input.color(color.navy, "Tuesday")
color mercredi  = input.color(color.olive, "Wednesday")
color jeudi     = input.color(color.purple, "Thursday")
color vendredi  = input.color(color.silver, "Friday")
color weekend   = input.color(color.teal, "Weekend")


monday          = color.new(lundi, 90)
tuesday         = color.new(mardi, 90)
wednesday       = color.new(mercredi, 90)
thursday        = color.new(jeudi, 90)
friday          = color.new(vendredi, 90)
sunday          = color.new(weekend, 90)

    
lol2 = dayofweek(time) == dayofweek.monday ? monday :  dayofweek(time) == dayofweek.tuesday ? tuesday : dayofweek(time) == dayofweek.wednesday ? wednesday : dayofweek(time) == dayofweek.thursday? thursday : dayofweek(time) == dayofweek.friday ? friday : sunday
bgcolor(color=colorDays? lol2:na)

is_newbar(res) =>
    t = time(res)
    not na(t) and (na(t[1]) or t > t[1])

xxx = is_newbar("D") ? 1 : 0
bgcolor(color= not separateDays? na :  xxx==1 ?color.black:na, transp=50)