CRYPTO MARKET SESSION ANALYZER INDICATOR
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © thequantscience

// @version=5
indicator(" Crypto Market Session Analyzer - The Quant Science ™ ", overlay = true)

/////////////////////////////// Code by The Quant Science ® ////////////////////////////////////

// -------------------------------- Crypto Market Session --------------------------------------
// HOW IT WORKS: Easy track crypto market session. 
// --------------------------------------------------------------------------------------------
// SETTING: Setting the session hours for your UTC and launch the script. 
// --------------------------------------------------------------------------------------------

// Update release 1.00 (11/15/2022)
    
/////////////////////////////// STARTING ALGORITHM BACKTEST ////////////////////////////////////

// ##########################################################################################
// ##########################################################################################

asia_session = input.session(
     defval = "2200-0900", 
     title = "Asia session: ",
     group = " ############# ASIA SESSION ############# ",
     tooltip = "Adjust hours on your UTC.")

euro_session = input.session(
     defval = "0900-1700", 
     title = "Euro session: ",
     group = " ############# EURO SESSION ############# ",
     tooltip = "Adjust hours on your UTC.")

america_session = input.session(
     defval = "1500-2200", 
     title = "Usa session: ",
     group = " ############# USA SESSION ############# ",
     tooltip = "Adjust hours on your UTC.")

// ##########################################################################################

AsiaSession(sessionTimes) =>
    not na(time(timeframe.period, sessionTimes))

asia = AsiaSession(asia_session)

EuroSession(sessionTimes) =>
    not na(time(timeframe.period, sessionTimes))

euro = EuroSession(euro_session)

AmericaSession(sessionTimes) =>
    not na(time(timeframe.period, sessionTimes))

usa = AmericaSession(america_session)

// ############################################################################################

bgcolor(asia ? color.new(color.blue, 90) : na)
bgcolor(euro ? color.new(color.purple, 90) : na)
bgcolor(usa ? color.new(color.aqua, 90) : na)

// #########################################################################################################

var tb = table.new(position.bottom_left, 1, 1, bgcolor = color.new(color.blue, 90))

if barstate.isfirst
    table.cell(tb, 0, 0, 
      'Developed by The Quant Science™'
      ,text_size = size.normal
      ,text_color = color.new(color.blue, 20))

// ############################################################################################
