Market Sessions Open/Close Levels
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=4

study(title="Market Sessions Open/Close Levels", shorttitle="Market Levels", overlay=true)


odl = input(true, title="Sydney/Daily Open")
dopen = security(syminfo.ticker, 'D', close[1], barmerge.gaps_off, barmerge.lookahead_on) 
dcolor = close < dopen ? color.red : color.blue
plot(odl and dopen ? dopen :na , title="Sydney/Daily Open",style=plot.style_linebr, color=dcolor, linewidth=3) 


UTCTimeInput = input('0930-0931', title="NYSE Open") 
UTCTimeInput2 = input('0800-0801', title="New York Open") 
UTCTimeInput3 = input('0300-0301', title="London Open") 
UTCTimeInput4 = input('1100-1101', title="London Close") 
UTCTimeInput5 = input('0200-0201', title="Frankfurt Open") 
UTCTimeInput7 = input('1900-1901', title="Tokyo Open") 




OpenValueTime = time("1", UTCTimeInput)
OpenValueTime2 = time("1", UTCTimeInput2)
OpenValueTime3 = time("1", UTCTimeInput3)
OpenValueTime4 = time("1", UTCTimeInput4)
OpenValueTime5 = time("1", UTCTimeInput5)
OpenValueTime7 = time("1", UTCTimeInput7)

var OpenPA = 0.0
if OpenValueTime
    if not OpenValueTime[1]
        OpenPA := open

var OpenPA2 = 0.0
if OpenValueTime2
    if not OpenValueTime2[1]
        OpenPA2 := open

var OpenPA3 = 0.0
if OpenValueTime3
    if not OpenValueTime3[1]
        OpenPA3 := open

var OpenPA4 = 0.0
if OpenValueTime4
    if not OpenValueTime4[1]
        OpenPA4 := open

var OpenPA5 = 0.0
if OpenValueTime5
    if not OpenValueTime5[1]
        OpenPA5 := open

        
var OpenPA7 = 0.0
if OpenValueTime7
    if not OpenValueTime7[1]
        OpenPA7 := open
        
        
plot(not OpenValueTime ? OpenPA : na, title="NYSE Open", color=color.black, linewidth=2, style=plot.style_linebr)
plot(not OpenValueTime2 ? OpenPA2 : na, title="New York Open", color=color.black, linewidth=2, style=plot.style_linebr)
plot(not OpenValueTime3 ? OpenPA3 : na, title="London Open", color=color.black, linewidth=2, style=plot.style_linebr)
plot(not OpenValueTime4 ? OpenPA4 : na, title="London Close", color=color.black, linewidth=2, style=plot.style_linebr)
plot(not OpenValueTime5 ? OpenPA5 : na, title="Frankfurt Open", color=color.black, linewidth=2, style=plot.style_linebr)
plot(not OpenValueTime7 ? OpenPA7 : na, title="Tokyo Open", color=color.black, linewidth=2, style=plot.style_linebr)




