AMDX-XAMD
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © minerlancer

//@version=5
indicator('AMDX-XAMD' , overlay = true , precision = 0 , max_boxes_count = 500 , max_labels_count = 500 , max_lines_count = 500 , max_bars_back = 5000)

Timezone = 'America/New_York'

DOM_240 = (timeframe.multiplier >= 240)
DOM240 = (timeframe.multiplier <= 240)
DOM60  = (timeframe.multiplier <= 60)
DOM40  = (timeframe.multiplier <= 40)
DOM30  = (timeframe.multiplier <= 30)
DOM15  = (timeframe.multiplier <= 15)
DOM5   = (timeframe.multiplier <= 5)

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// AMDX / XDMA
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

//---Weekly
show_Q_W = input.bool(defval = false , title = 'AMDX W' , inline = '0' , group = 'AMDX Weekly')
color_Q_W= input.color(defval = color.rgb(54, 58, 69, 50) , title = '' , inline = '0' , group = 'AMDX Weekly')
open_Q_W = input.bool(defval = false  , title = 'Line Open True W', inline = '1' , group = 'AMDX Weekly')
ln_cl_Q_W= input.color(defval = color.black , title = '' , inline = '1' , group = 'AMDX Weekly')
show_txt_open_Q_W = input.bool(defval = false , title = 'Text Open' , inline = '1', group = 'AMDX Weekly')
show_txt_Q_W = input.bool(defval = false , title = 'Text in Box  ' , inline = '2', group = 'AMDX Weekly')
tran_txt_Q_W = input.int(defval = 70 , title = 'Trasparency Text' , maxval = 100 , inline = '2', group = 'AMDX Weekly')

//---Dayly
show_Q_D = input.bool(defval = true , title = 'AMDX D' , inline = '0' , group = 'AMDX Daily')
open_Q_D = input.bool(defval = false  , title = 'Line Open True D  ' , inline = '1' , group = 'AMDX Daily')
show_txt_open_Q_D = input.bool(defval = false , title = 'Text Open' , inline = '1', group = 'AMDX Daily')
show_txt_Q_D = input.bool(defval = false , title = 'Text in Box  ' , inline = '2' , group = 'AMDX Daily')
tran_txt_Q_D =  input.int(defval = 70 , title = 'Trasparency Text' , maxval = 100 , inline = '2' , group = 'AMDX Daily')

//---Session
show_Q_Sess    = input.bool(defval = false , title = 'AMDX Session' , inline = '0' , group = 'AMDX Session')
show_open_True_Sess_Q1 = input.bool(defval = true , title = 'Asian '  , inline = '1' , group = 'AMDX Session')
show_open_True_Sess_Q2 = input.bool(defval = true , title = 'London ' , inline = '1' , group = 'AMDX Session')
show_open_True_Sess_Q3 = input.bool(defval = true , title = 'NY '     , inline = '1' , group = 'AMDX Session')
show_open_True_Sess_Q4 = input.bool(defval = true , title = 'PM '     , inline = '1' , group = 'AMDX Session')
show_Q_BR_box  = input.bool(defval = true  , title = 'BG Box  ' , inline = '2' , group = 'AMDX Session')
show_Q_txt_box = input.bool(defval = false , title = 'Text Box' , inline = '2' , group = 'AMDX Session')
show_Q_txt_up  = input.bool(defval = false , title = 'Text Session' , inline = '2' , group = 'AMDX Session' , tooltip = 'Show in TF 5m')

show_open_True = input.bool(defval = true  , title = 'Line Open True Session  ' , inline = '3' , group = 'AMDX Session')
show_txt_open_True = input.bool(defval = true , title = 'Text Open'  , inline = '3' , group = 'AMDX Session')

[dailyTime, dailyOpen] = request.security(syminfo.tickerid, 'D', [time, open], lookahead=barmerge.lookahead_on)

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Open True
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

txt_True_W    = 'Weekly'
col_True_W    = ln_cl_Q_W
timing_True_W = dayofweek(time_close) == dayofweek.monday and  (hour(time, Timezone) == 18) and (minute(time) == 00) 

txt_True_D    = 'Daily'
col_True_D    = color.orange
timing_True_D = (hour(time, Timezone) == 00) and (minute(time) == 00) 

txt_True_0    = 'Asian'
col_True_0    = color.white
timing_True_0 = (hour(time, Timezone) == 19) and (minute(time) == 30) 

txt_True_1    = 'London'
col_True_1    = color.blue
timing_True_1 = (hour(time, Timezone) == 01) and (minute(time) == 30) 

txt_True_2    = 'NY'
col_True_2    = color.red
timing_True_2 = (hour(time, Timezone) == 07) and (minute(time) == 30) 

txt_True_3    = 'PM'
col_True_3    = color.purple
timing_True_3 = (hour(time, Timezone) == 13) and (minute(time) == 30) 

//-----True open Weekly
var line[] line_W  = array.new_line(0)
var label[] labl_W = array.new_label(0)
if open_Q_W and DOM240 and not timeframe.ismonthly
    if timing_True_W and not timing_True_W[1]
        array.push(line_W , line.new(time , open , time + 80 * 3600000 , open , xloc = xloc.bar_time , color = col_True_W , width = 2))
        array.push(labl_W , label.new(time + 80 * 3600000 , open , show_txt_open_Q_W ? txt_True_W : na , xloc = xloc.bar_time , style = label.style_none ,  size = size.small ,  textcolor = col_True_W))

//-----True open Daily
var line[] line_D  = array.new_line(0)
var label[] labl_D = array.new_label(0)
if open_Q_D and DOM240
    if timing_True_D and not timing_True_D[1]
        array.push(line_D , line.new(time , open , time + 23 * 3600000 , open , xloc = xloc.bar_time , color = col_True_D , width = 2))
        array.push(labl_D , label.new(time + 23 * 3600000 , open , show_txt_open_Q_D ? txt_True_D : na , xloc = xloc.bar_time , style = label.style_none ,  size = size.small ,  textcolor = col_True_D))

//-----True open Session
var line[] l1   = array.new_line(0)
var label[] la1 = array.new_label(0)
var line[] l2   = array.new_line(0)
var label[] la2 = array.new_label(0)
var line[] l3   = array.new_line(0)
var label[] la3 = array.new_label(0)
var line[] l4   = array.new_line(0)
var label[] la4 = array.new_label(0)
_extend = 4 * 3600000
if show_open_True and DOM30 and not timeframe.ismonthly
    if timing_True_0 and not timing_True_0[1] and show_open_True_Sess_Q1
        array.push(l1, line.new(time , open , time + _extend , open , xloc = xloc.bar_time , color = col_True_0 , width = 1))
        array.push(la1 , label.new(time + _extend , open , show_txt_open_True ? txt_True_0 : na , xloc=xloc.bar_time ,  style=label.style_none ,  size=size.small ,  textcolor = col_True_0))
    if timing_True_1 and not timing_True_1[1] and show_open_True_Sess_Q2
        array.push(l2 , line.new(time , open , time + _extend ,  open , xloc=xloc.bar_time ,  color = col_True_1 ,  width = 1))
        array.push(la2 , label.new(time + _extend, open, show_txt_open_True ? txt_True_1 : na , xloc = xloc.bar_time , style = label.style_none , size = size.small , textcolor = col_True_1))
    if timing_True_2 and not timing_True_2[1] and show_open_True_Sess_Q3
        array.push(l3 , line.new(time , open , time + _extend , open , xloc=xloc.bar_time, color = col_True_2 , width = 1))
        array.push(la3 , label.new(time + _extend, open, show_txt_open_True ? txt_True_2 : na , xloc = xloc.bar_time , style = label.style_none , size = size.small, textcolor = col_True_2))
    if timing_True_3 and not timing_True_3[1] and show_open_True_Sess_Q4
        array.push(l4 , line.new(time , open , time + _extend , open , xloc = xloc.bar_time , color = col_True_3 , width = 1))
        array.push(la4 , label.new(time + _extend , open , show_txt_open_True ? txt_True_3 : na , xloc = xloc.bar_time , style = label.style_none, size = size.small , textcolor = col_True_3))

// Delete lines if more than max
if array.size(l1) > 10
    line.delete(array.shift(l1))
    label.delete(array.shift(la1))
if array.size(l1) > 10
    line.delete(array.shift(l2))
    label.delete(array.shift(la2))
if array.size(l3) > 10
    line.delete(array.shift(l3))
    label.delete(array.shift(la3))
if array.size(l4) > 10
    line.delete(array.shift(l4))
    label.delete(array.shift(la4))

//--------------------------------
//---Function 
//--------------------------------
drawing_VerticalLines(aBaseTime, aDrawTimeD, aLineStyle, aLineColor) =>
    _iDrawTimeD = aDrawTimeD

    yy = year
    mm = month
    dd = dayofmonth
    hh = hour(aBaseTime)
    m2 = minute(aBaseTime)

    iDrawTime = timestamp(yy, mm, dd, hh, m2)

    hour_j = hour(iDrawTime, Timezone)
    dayofweek_j = dayofweek(iDrawTime, Timezone)

    iDsp = true
    if dayofweek_j == dayofweek.saturday and hour_j >= 6
        iDsp := false
    else if dayofweek_j == dayofweek.sunday
        iDsp := false
    else if dayofweek_j == dayofweek.monday and hour_j < 7
        iDsp := false

    // double drawing prevention
    if iDrawTime != aDrawTimeD and iDsp
        line.new(iDrawTime, dailyOpen, iDrawTime, dailyOpen + syminfo.mintick, xloc=xloc.bar_time, style=aLineStyle, extend=extend.both, color=aLineColor, width=1)
        _iDrawTimeD := iDrawTime
    _iDrawTimeD
//--------------------------------------------

//--------------------------------------------
//--Functions 
in_session(sess) =>
    not na(time(timeframe.period, sess, Timezone))
start_time(sess) =>
    int startTime = na
    startTime := in_session(sess) and not in_session(sess)[1] ? time : startTime[1]
    startTime
is_new_session(res, sess) =>
    t = time(res, sess, Timezone)
    na(t[1]) and not na(t) or t[1] < t
//--------------------------------------------

//-------------------------------------------
//--Timing Session
//---Q1
time_Q_ses_D = timeframe.period == '240' ? '0000-2200' : '0000-2300'
Q_ses_D  = time_Q_ses_D

//--Timing Session
//---Q1
Q_ses_AS  = '1800-0000'
Q_time_0  = '1800-1930'
Q_time_1  = '1930-2100'
Q_time_2  = '2100-2230' 
Q_time_3  = '2230-0000'
//---Q2
Q_ses_LN  = '0000-0600'
Q_time_4  = '0000-0130'
Q_time_5  = '0130-0300'
Q_time_6  = '0300-0430'
Q_time_7  = '0430-0600' 
//---Q3
Q_ses_NY  = '0600-1200'
Q_time_8  = '0600-0730'
Q_time_9  = '0730-0900' 
Q_time_10 = '0900-1030'
Q_time_11 = '1030-1200' 
//---Q4
Q_ses_PM  = '1200-1800'
Q_time_12 = '1200-1330'
Q_time_13 = '1330-1500'
Q_time_14 = '1500-1630' 
Q_time_15 = '1630-1800' 
//-------------------------------------------

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Box
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
time_start  = timestamp(Timezone , year , month , dayofmonth , 9, 30 , 00)

// ======= Range + Box ========
ictbox(kz , bdcol , bgcol , txt, coltxt , x)=>
    sesh = is_new_session('1440', kz)
    float kzlow = na
    float kzhigh = na
    float kzbodlow = na
    float kzbodhigh = na

    kzbox = box(na)
    bline = line(na)
    bline2 = line(na)
    kzstart = start_time(kz)
    kzlow := sesh ? low : in_session(kz) ? math.min(low, kzlow[1]) : na
    kzhigh := sesh ? high : in_session(kz) ? math.max(high, kzhigh[1]) : na
    
    if in_session(kz)
        if in_session(kz)[1]
            box.delete(kzbox[1])
            line.delete(bline[1])
            line.delete(bline2[1])
        if low < kzlow
            kzlow := low
            kzlow
        if high > kzhigh
            kzhigh := high
            kzhigh     
        if x
            kzbox := box.new(kzstart , kzhigh , time , kzlow , bdcol , 1 , line.style_solid , extend.none , xloc.bar_time , bgcol , txt , size.auto , coltxt , text_wrap = text.wrap_auto , text_valign = text.align_top)
            kzbox
        if x 
            bline := line.new(kzstart, kzhigh, time, kzhigh, xloc.bar_time, extend.none, bdcol, line.style_solid, 1)
            bline
            bline2 := line.new(kzstart, kzlow, time, kzlow, xloc.bar_time, extend.none, bdcol, line.style_solid, 1)
            bline2
    tz = time - time[1]
//---------------------
//---W = Day of Week
bg_friday = DOM_240 and dayofweek(time_close) == dayofweek.friday ? color.new(color.gray , 60) : na
bgcolor(color = bg_friday , title = 'Friday')

txt_Q_W = dayofweek(time_close) == dayofweek.monday ? 'Q1 \nMonday' : dayofweek(time_close) == dayofweek.tuesday ? 'Q2 \nTuesday' : dayofweek(time_close) == dayofweek.wednesday ? 'Q3 \nWednesday' : dayofweek(time_close) == dayofweek.thursday  ? 'Q4 \nThursday' : na
col_Q_W = dayofweek(time_close) == dayofweek.friday ? color.rgb(255, 82, 82, 100) : color_Q_W
col_txt_W_AMDX = show_txt_Q_W ? color.new(color.gray, tran_txt_Q_W) : na
if DOM240 and not timeframe.ismonthly
    ictbox(Q_ses_D , col_Q_W , color.rgb(0, 187, 212, 100) , txt_Q_W , col_txt_W_AMDX , show_Q_W)

//-------------------------
//---D
col_txt_D_AMDX = show_txt_Q_D ? color.new(color.gray , tran_txt_Q_D) : na
if DOM60 and not timeframe.isdwm
    ictbox(Q_ses_AS , color.new(col_True_0 , 70) , color.rgb(0, 187, 212, 100) , 'Q1 \nAsia' , col_txt_D_AMDX , show_Q_D)
    ictbox(Q_ses_LN , color.new(col_True_1 , 70) , color.rgb(0, 187, 212, 100) , 'Q2 \nLondon' , col_txt_D_AMDX , show_Q_D)
    ictbox(Q_ses_NY , color.new(col_True_2 , 70) , color.rgb(0, 187, 212, 100) , 'Q3 \nNY' , col_txt_D_AMDX , show_Q_D)
    ictbox(Q_ses_PM , color.new(col_True_3 , 70) , color.rgb(0, 187, 212, 100) , 'Q4 \nPM' , col_txt_D_AMDX , show_Q_D)
//-------------------------

col_txt_session_AMDX = show_Q_txt_box ? color.new(color.gray, 80) : na
if DOM30 and show_Q_Sess
    if show_open_True_Sess_Q1 and not timeframe.isdwm
        ictbox(Q_time_0 , color.new(col_True_0 , 50) , show_Q_BR_box ? color.new(col_True_0 , 90) : na , 'Q1' , col_txt_session_AMDX , show_Q_Sess)  
        ictbox(Q_time_1 , color.new(col_True_0 , 50) , show_Q_BR_box ? color.new(col_True_0 , 90) : na , 'Q2' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_2 , color.new(col_True_0 , 50) , show_Q_BR_box ? color.new(col_True_0 , 90) : na , 'Q3' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_3 , color.new(col_True_0 , 50) , show_Q_BR_box ? color.new(col_True_0 , 90) : na , 'Q4' , col_txt_session_AMDX , show_Q_Sess)
    if show_open_True_Sess_Q2
        ictbox(Q_time_4 , color.new(col_True_1 , 50) , show_Q_BR_box ? color.new(col_True_1 , 90) : na , 'Q1' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_5 , color.new(col_True_1 , 50) , show_Q_BR_box ? color.new(col_True_1 , 90) : na , 'Q2' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_6 , color.new(col_True_1 , 50) , show_Q_BR_box ? color.new(col_True_1 , 90) : na , 'Q3' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_7 , color.new(col_True_1 , 50) , show_Q_BR_box ? color.new(col_True_1 , 90) : na , 'Q4' , col_txt_session_AMDX , show_Q_Sess)
    if show_open_True_Sess_Q3
        ictbox(Q_time_8 , color.new(col_True_2 , 50) , show_Q_BR_box ? color.new(col_True_2 , 90) : na , 'Q1' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_9 , color.new(col_True_2 , 50) , show_Q_BR_box ? color.new(col_True_2 , 90) : na , 'Q2' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_10, color.new(col_True_2 , 50) , show_Q_BR_box ? color.new(col_True_2 , 90) : na , 'Q3' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_11, color.new(col_True_2 , 50) , show_Q_BR_box ? color.new(col_True_2 , 90) : na , 'Q4' , col_txt_session_AMDX , show_Q_Sess)
    if show_open_True_Sess_Q4
        ictbox(Q_time_12, color.new(col_True_3 , 50) , show_Q_BR_box ? color.new(col_True_3 , 90) : na , 'Q1' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_13, color.new(col_True_3 , 50) , show_Q_BR_box ? color.new(col_True_3 , 90) : na , 'Q2' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_14, color.new(col_True_3 , 50) , show_Q_BR_box ? color.new(col_True_3 , 90) : na , 'Q3' , col_txt_session_AMDX , show_Q_Sess)
        ictbox(Q_time_15, color.new(col_True_3 , 50) , show_Q_BR_box ? color.new(col_True_3 , 90) : na , 'Q4' , col_txt_session_AMDX , show_Q_Sess)

//--------------------------------
//--Label session
//--------------------------------
if DOM5 and not timeframe.isdwm
    var float top_bottom = 0
    var color kz_color   = na
    var bool in_kz       = na
    var string kz_text   = na
    if show_Q_txt_up
        if show_open_True_Sess_Q1 and time(timeframe.period , '1801-0000' , Timezone)
            in_kz := true , kz_color := color.new(col_True_0 , 80) , kz_text := txt_True_0 

        else if show_open_True_Sess_Q2 and time(timeframe.period , '0001-0600' , Timezone)
            in_kz := true , kz_color := color.new(col_True_1 , 80) , kz_text := txt_True_1 

        else if show_open_True_Sess_Q3 and time(timeframe.period , '0601-1200' , Timezone)
            in_kz := true , kz_color := color.new(col_True_2 , 80) , kz_text := txt_True_2

        else if show_open_True_Sess_Q4 and time(timeframe.period , '1201-1800' , Timezone)
            in_kz := true , kz_color := color.new(col_True_3 , 80) , kz_text := txt_True_3 
        else
            in_kz := false
    else
        in_kz := true

	var box kz_box = na
    var line kz_start_line = na
    var line kz_end_line = na

    if show_Q_txt_up
        if in_kz and not in_kz[1]
            kz_box := box.new(bar_index, high, bar_index, low, border_color = color.new(color.red, 100), bgcolor = kz_color, text = kz_text , text_size = size.small)
            kz_start_line := line.new(bar_index, high, bar_index, box.get_top(kz_box), color = kz_color, style = line.style_dotted)
            top_bottom := 0
        if in_kz[1]
            box.set_right(kz_box, bar_index)
            if high > box.get_bottom(kz_box)
                box.set_bottom(kz_box,1.0010* high)
                box.set_top(kz_box,1.0015*high)
                line.set_y2(kz_start_line, box.get_top(kz_box))
        if in_kz[1] and not in_kz
            kz_end_line := line.new(bar_index, high, bar_index, box.get_top(kz_box), color = kz_color, style = line.style_dotted)



