Dashboard (chlo) - v1
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © karthiksundaram111

//@version=5
indicator(title="Dashboard (chlo)", overlay=true)

// ---- Table Settings Start {----//
max    = 160    //Maximum Length
min    = 10     //Minimum Length
var stocks = "Shows Symbols for the selected Index"
var ltp = "Shows LTP of symbols"

dash_loc = input.session("Bottom Right","Dashboard Location"  ,options=["Top Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"]  ,group='Style Settings')

text_size = input.session('Small',"Dashboard Size"  ,options=["Tiny","Small","Normal","Large"]  ,group='Style Settings')

cell_up = input.color(#237a27,'Buy Cell Color'  ,group='Style Settings')
cell_dn = input.color(color.red,'Sell Cell Color'  ,group='Style Settings')
cell_Neut = input.color(color.gray,'Neut Cell Color'  ,group='Style Settings')
row_col = color.blue
col_col = color.blue
txt_col = color.white
cell_transp = input.int(60,'Cell Transparency'  ,minval=0  ,maxval=100  ,group='Style Settings')
// ---- Table Settings End ----}//

// ---- Indicators Show/Hide Settings Start {----//
showLTP = input.bool(defval=true, title="Show LTP :", inline='indicator1', group="Columns Settings")
showhigh = input.bool(defval=true, title="Show high", inline='indicator1', group="Columns Settings")
showlow = input.bool(defval=true, title="Show low", inline='indicator1', group="Columns Settings")
showopen = input.bool(defval=true, title="Show open", inline='indicator1', group="Columns Settings")

// ---- Symbols Show/Hide Settings Start {----//
showSiv = input.bool(defval=true, title="Show India VIX", group="Rows Settings")
showS1 = input.bool(defval=true, title="Show Symbol 1 :", inline='SSym1', group="Rows Settings")
showS2 = input.bool(defval=true, title="Show Symbol 2", inline='SSym1', group="Rows Settings")
showS3 = input.bool(defval=true, title="Show Symbol 3 :", inline='SSym2', group="Rows Settings")
showS4 = input.bool(defval=true, title="Show Symbol 4", inline='SSym2', group="Rows Settings")
showS5 = input.bool(defval=true, title="Show Symbol 5 :", inline='SSym3', group="Rows Settings")
showS6 = input.bool(defval=true, title="Show Symbol 6", inline='SSym3', group="Rows Settings")
showS7 = input.bool(defval=true, title="Show Symbol 7 :", inline='SSym4', group="Rows Settings")
showS8 = input.bool(defval=true, title="Show Symbol 8", inline='SSym4', group="Rows Settings")
showS9 = input.bool(defval=true, title="Show Symbol 9 :", inline='SSym5', group="Rows Settings")
showS10 = input.bool(defval=true, title="Show Symbol 10", inline='SSym5', group="Rows Settings")
// ---- Symbols Show/Hide Settings end ----}//

//---- Index & Symbols Selection code start {----//
_Index = input.string('BankNifty', 'Dashboard for Index', options=['BankNifty', 'Nifty'], group='Symbol Settings')

t1 = _Index == 'BankNifty' ? input.symbol('NSE:BANKNIFTY', 'BNF Symbol 1', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:NIFTY', 'Nifty Symbol 1', inline='Nifty Symbol', group='Symbol Settings')
t2 = _Index == 'BankNifty' ? input.symbol('NSE:BANKNIFTY1!', 'BNF Symbol 2', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:NIFTY1!', 'Nifty Symbol 2',  inline='Nifty Symbol', group='Symbol Settings')
t3 = _Index == 'BankNifty' ? input.symbol('NSE:HDFCBANK', 'BNF Symbol 3', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:RELIANCE', 'Nifty Symbol 3',  inline='Nifty Symbol', group='Symbol Settings')
t4 = _Index == 'BankNifty' ? input.symbol('NSE:ICICIBANK', 'BNF Symbol 4', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:INFY', 'Nifty Symbol 4',  inline='Nifty Symbol', group='Symbol Settings')
t5 = _Index == 'BankNifty' ? input.symbol('NSE:KOTAKBANK', 'BNF Symbol 5', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:HDFCBANK', 'Nifty Symbol 5',  inline='Nifty Symbol', group='Symbol Settings')
t6 = _Index == 'BankNifty' ? input.symbol('NSE:AXISBANK', 'BNF Symbol 6', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:ICICIBANK', 'Nifty Symbol 6',  inline='Nifty Symbol', group='Symbol Settings')
t7 = _Index == 'BankNifty' ? input.symbol('NSE:SBIN', 'BNF Symbol 7', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:HDFC', 'Nifty Symbol 7',  inline='Nifty Symbol', group='Symbol Settings')
t8 = _Index == 'BankNifty' ? input.symbol('NSE:INDUSINDBK', 'BNF Symbol 8', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:TCS', 'Nifty Symbol 8',  inline='Nifty Symbol', group='Symbol Settings')
t9 = _Index == 'BankNifty' ? input.symbol('NSE:AUBANK', 'BNF Symbol 9', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:KOTAKBANK', 'Nifty Symbol 9',  inline='Nifty Symbol', group='Symbol Settings')
t10 = _Index == 'BankNifty' ? input.symbol('NSE:BANDHANBNK', 'BNF Symbol 10', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:LT', 'Nifty Symbol 10',  inline='Nifty Symbol', group='Symbol Settings')
//---- Index & Symbols Selection code end ----}//

//---- get security values {----//
[ts1,ts1O,ts1H,ts1L] = request.security(t1,'D',[close,open,high,low])
//------------------
[ts2,ts2O,ts2H,ts2L] = request.security(t2,'D',[close,open,high,low])
//---------------
[ts3,ts3O,ts3H,ts3L] = request.security(t3,'D',[close,open,high,low])
//----------------
[ts4,ts4O,ts4H,ts4L] = request.security(t4,'D',[close,open,high,low])
//----------------
[ts5,ts5O,ts5H,ts5L] = request.security(t5,'D',[close,open,high,low])
//----------------
[ts6,ts6O,ts6H,ts6L] = request.security(t6,'D',[close,open,high,low])
//----------------
[ts7,ts7O,ts7H,ts7L] = request.security(t7,'D',[close,open,high,low])
//----------------
[ts8,ts8O,ts8H,ts8L] = request.security(t8,'D',[close,open,high,low])
//----------------
[ts9,ts9O,ts9H,ts9L] = request.security(t9,'D',[close,open,high,low])
//----------------
[ts10,ts10O,ts10H,ts10L] = request.security(t10,'D',[close,open,high,low])

//-------------- Table code Start {-------------------//

//---- Table Position & Size code start {----//
var table_position = dash_loc == 'Top Left' ? position.top_left :
  dash_loc == 'Bottom Left' ? position.bottom_left :
  dash_loc == 'Middle Right' ? position.middle_right :
  dash_loc == 'Bottom Center' ? position.bottom_center :
  dash_loc == 'Top Right' ? position.top_right : position.bottom_right
  
var table_text_size = text_size == 'Tiny' ? size.tiny :
  text_size == 'Small' ? size.small :
  text_size == 'Normal' ? size.normal : size.large

var t = table.new(table_position,15,math.abs(max-min)+2,
  frame_color=color.new(#000000,0),
  frame_width=1,
  border_color=color.new(#000000,0),
  border_width=1)
//---- Table Position & Size code end ----}//


if (barstate.islast)
    if showLTP
        table.cell(t,2,1,'LTP',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,60))
        table.cell(t,3,1,'high',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,60) )
        table.cell(t,4,1,'low',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,60))
        table.cell(t,5,1,'open',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,60))
//---- Display Symbol-1 data code start {----//
    if showS1
        table.cell(t,1,3, str.replace_all(t1, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS1 and showLTP
        table.cell(t,2,3, str.tostring(ts1, '#') ,text_color=color.green ,text_size=table_text_size)
    if showS1 and showhigh
        table.cell(t,3,3, str.tostring(ts1H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS1 and showlow
        table.cell(t,4,3, str.tostring(ts1L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS1 and showopen
        table.cell(t,5,3, str.tostring(ts1O, '#') ,text_color=color.black ,text_size=table_text_size) 
//---- Display Symbol-2 data code start {----//
    if showS2 
        table.cell(t,1,4, str.replace_all(t2, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS2 and showLTP
        table.cell(t,2,4, str.tostring(ts2, '#') ,text_color=color.green,text_size=table_text_size)   
    if showS2 and showhigh
        table.cell(t,3,4, str.tostring(ts2H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS2 and showlow
        table.cell(t,4,4, str.tostring(ts2L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS2 and showopen
        table.cell(t,5,4, str.tostring(ts2O, '#') ,text_color=color.black ,text_size=table_text_size) 

//---- Display Symbol-3 data code start {----//
    if showS3
        table.cell(t,1,5, str.replace_all(t3, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS3 and showLTP
        table.cell(t,2,5, str.tostring(ts3, '#') ,text_color=color.green, text_size=table_text_size)
    if showS3 and showhigh
        table.cell(t,3,5, str.tostring(ts3H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS3 and showlow
        table.cell(t,4,5, str.tostring(ts3L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS3 and showopen
        table.cell(t,5,5, str.tostring(ts3O, '#') ,text_color=color.black ,text_size=table_text_size)     
        
//---- Display Symbol-4 data code start {----//
    if showS4 
        table.cell(t,1,6, str.replace_all(t4, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS4 and showLTP
        table.cell(t,2,6, str.tostring(ts4, '#') ,text_color=color.green ,text_size=table_text_size)        
    if showS3 and showhigh
        table.cell(t,3,6, str.tostring(ts4H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS3 and showlow
        table.cell(t,4,6, str.tostring(ts4L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS3 and showopen
        table.cell(t,5,6, str.tostring(ts4O, '#') ,text_color=color.black ,text_size=table_text_size)     
        
//---- Display Symbol-5 data code start {----//
    if showS5
        table.cell(t,1,7, str.replace_all(t5, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS5 and showLTP
        table.cell(t,2,7, str.tostring(ts5, '#') ,text_color=color.green,text_size=table_text_size )        
    if showS5 and showhigh
        table.cell(t,3,7, str.tostring(ts5H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS5 and showlow
        table.cell(t,4,7, str.tostring(ts5L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS5 and showopen
        table.cell(t,5,7, str.tostring(ts5O, '#') ,text_color=color.black ,text_size=table_text_size) 
        
//---- Display Symbol-6 data code start {----//
    if showS6
        table.cell(t,1,8, str.replace_all(t6, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS6 and showLTP
        table.cell(t,2,8, str.tostring(ts6, '#') ,text_color=color.green,text_size=table_text_size)   
    if showS6 and showhigh
        table.cell(t,3,8, str.tostring(ts6H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS6 and showlow
        table.cell(t,4,8, str.tostring(ts6L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS6 and showopen
        table.cell(t,5,8, str.tostring(ts6O, '#') ,text_color=color.black ,text_size=table_text_size) 
        
//---- Display Symbol-7 data code start {----//
    if showS7
        table.cell(t,1,9, str.replace_all(t7, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS7 and showLTP
        table.cell(t,2,9, str.tostring(ts7, '#') ,text_color=color.green, text_size=table_text_size)
    if showS7 and showhigh
        table.cell(t,3,9, str.tostring(ts7H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS7 and showlow
        table.cell(t,4,9, str.tostring(ts7L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS7 and showopen
        table.cell(t,5,9, str.tostring(ts7O, '#') ,text_color=color.black ,text_size=table_text_size) 
        
//---- Display Symbol-8 data code start {----//
    if showS8
        table.cell(t,1,10, str.replace_all(t8, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS8 and showLTP
        table.cell(t,2,10, str.tostring(ts8, '#') ,text_color=color.green,text_size=table_text_size) 
    if showS8 and showhigh
        table.cell(t,3,10, str.tostring(ts8H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS8 and showlow
        table.cell(t,4,10, str.tostring(ts8L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS8 and showopen
        table.cell(t,5,10, str.tostring(ts8O, '#') ,text_color=color.black ,text_size=table_text_size) 
        
//---- Display Symbol-9 data code start {----//
    if showS9
        table.cell(t,1,11, str.replace_all(t9, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS9 and showLTP
        table.cell(t,2,11, str.tostring(ts9, '#') ,text_color=color.green ,text_size=table_text_size ) 
    if showS9 and showhigh
        table.cell(t,3,11, str.tostring(ts9H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS9 and showlow
        table.cell(t,4,11, str.tostring(ts9L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS9 and showopen
        table.cell(t,5,11, str.tostring(ts9O, '#') ,text_color=color.black ,text_size=table_text_size) 
        
//---- Display Symbol-10 data code start {----//
    if showS10
        table.cell(t,1,12, str.replace_all(t10, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
    if showS10 and showLTP
        table.cell(t,2,12, str.tostring(ts10, '#') ,text_color=color.green ,text_size=table_text_size)         
    if showS10 and showhigh
        table.cell(t,3,12, str.tostring(ts10H, '#') ,text_color=color.red ,text_size=table_text_size)
    if showS10 and showlow
        table.cell(t,4,12, str.tostring(ts10L, '#') ,text_color=color.orange ,text_size=table_text_size)
    if showS10 and showopen
        table.cell(t,5,12, str.tostring(ts10O, '#') ,text_color=color.black ,text_size=table_text_size)     
        
        
        