BankNifty Dash
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tradeblinks
//@version=5

indicator(title="Nifty/Banknifty Dash", overlay=true)
// Dash Settings
max    = 120    //Maximum Length
min    = 10     //Minimum Length
dash_loc = input.session("Top Right","Dashboard Location"  ,options=["Top Right", "Bottom Right", "Middle Right", "Top Left", "Bottom Left"]  ,group='Dash Settings')
text_size = input.session('Small',"Dashboard Size"  ,options=["Small","Big"]  ,group='Dash Settings')
cell_up = color.green
cell_dn = color.red
cell_neutral = color.black
row_col = color.blue
col_col = color.blue
txt_col = color.white
cell_transp = 80

// Index & Symbols
_Index = input.string('BankNifty', 'Dashboard for Index', options=['BankNifty', 'Nifty'], group='Dash Settings')
t1 = _Index == 'BankNifty' ? 'NSE:NIFTY': 'NSE:INDIAVIX'
t2 = _Index == 'BankNifty' ? 'NSE:BANKNIFTY':'NSE:NIFTY'
t3 = _Index == 'BankNifty' ? 'NSE:HDFCBANK':'NSE:RELIANCE'
t4 = _Index == 'BankNifty' ? 'NSE:ICICIBANK':'NSE:HDFCBANK'
t5 = _Index == 'BankNifty' ? 'NSE:KOTAKBANK':'NSE:ICICIBANK'
t6 = _Index == 'BankNifty' ? 'NSE:AXISBANK':'NSE:INFY'
t7 = _Index == 'BankNifty' ? 'NSE:SBIN':'NSE:HDFC'
t8 = _Index == 'BankNifty' ? 'NSE:INDUSINDBK':'NSE:TCS'
t9 = _Index == 'BankNifty' ? 'NSE:BANKBARODA':'NSE:ITC'
t10 = _Index == 'BankNifty' ? 'NSE:AUBANK':'NSE:LT'
// Participation
[indexLTP] = request.security(_Index == 'BankNifty' ?'NSE:BANKNIFTY':'NSE:NIFTY', 'D', [close])
//HDFC BANK = 28.66
//ICICI BANK = 23.54
//KOTAK BANK = 10.18
//AXIS BANK = 10.01
//SBI =9.85
//INDUSIND BANK = 5.91
//BANK OF BARODA = 2.62
//AU BANK = 2.49

//RELIANCE = 10.41
//HDFC BANK = 9.06
//ICICI BANK = 7.44
//INFOSYS = 7.20
//HDFC = 6.06
//TCS = 4.41
//ITC = 3.98
//LT = 3.29
s1= _Index == 'BankNifty' ? 0.2866 : 0.1041
s2= _Index == 'BankNifty' ? 0.2354 : 0.0906
s3= _Index == 'BankNifty' ? 0.1018 : 0.0744
s4= _Index == 'BankNifty' ? 0.1001 : 0.0720
s5= _Index == 'BankNifty' ? 0.0985 : 0.0606
s6= _Index == 'BankNifty' ? 0.0591 : 0.0441
s7= _Index == 'BankNifty' ? 0.0262 : 0.0398
s8= _Index == 'BankNifty' ? 0.0249 : 0.0329

//Calculate IPV, Change & %Change
[ts1ltp,ts1high,ts1low,ts1PDH,ts1PDL,ts1pclose] = request.security(t1,'D',[close,high,low,high[1],low[1],close[1]])
ts1Chng = (ts1ltp-ts1pclose)
[ts2ltp,ts2high,ts2low,ts2PDH,ts2PDL,ts2pclose] = request.security(t2,'D',[close,high,low,high[1],low[1],close[1]])
ts2Chng = (ts2ltp-ts2pclose)
[ts3ltp,ts3high,ts3low,ts3PDH,ts3PDL,ts3pclose] = request.security(t3,'D',[close,high,low,high[1],low[1],close[1]])
changeValue3 = (ts3ltp-ts3pclose)
changePer3 = (changeValue3/ts3pclose)
IPV1 = (indexLTP*s1*changePer3)
[ts4ltp,ts4high,ts4low,ts4PDH,ts4PDL,ts4pclose] = request.security(t4,'D',[close,high,low,high[1],low[1],close[1]])
changeValue4 = (ts4ltp-ts4pclose)
changePer4 = (changeValue4/ts4pclose)
IPV2 = (indexLTP*s2*changePer4)
[ts5ltp,ts5high,ts5low,ts5PDH,ts5PDL,ts5pclose] = request.security(t5,'D',[close,high,low,high[1],low[1],close[1]])
changeValue5 = (ts5ltp-ts5pclose)
changePer5 = (changeValue5/ts5pclose)
IPV3 = (indexLTP*s3*changePer5) 
[ts6ltp,ts6high,ts6low,ts6PDH,ts6PDL,ts6pclose] = request.security(t6,'D',[close,high,low,high[1],low[1],close[1]])
changeValue6 = (ts6ltp-ts6pclose)
changePer6 = (changeValue6/ts6pclose)
IPV4 = (indexLTP*s4*changePer6)
[ts7ltp,ts7high,ts7low,ts7PDH,ts7PDL,ts7pclose] = request.security(t7,'D',[close,high,low,high[1],low[1],close[1]])
changeValue7 = (ts7ltp-ts7pclose)
changePer7 = (changeValue7/ts7pclose)
IPV5 = (indexLTP*s5*changePer7)
[ts8ltp,ts8high,ts8low,ts8PDH,ts8PDL,ts8pclose] = request.security(t8,'D',[close,high,low,high[1],low[1],close[1]])
changeValue8 = (ts8ltp-ts8pclose)
changePer8 = (changeValue8/ts8pclose)
IPV6 = (indexLTP*s6*changePer8)
[ts9ltp,ts9high,ts9low,ts9PDH,ts9PDL,ts9pclose] = request.security(t9,'D',[close,high,low,high[1],low[1],close[1]])
changeValue9 = (ts9ltp-ts9pclose)
changePer9 = (changeValue9/ts9pclose)
IPV7 = (indexLTP*s7*changePer9)
[ts10ltp,ts10high,ts10low,ts10PDH,ts10PDL,ts10pclose] = request.security(t10,'D',[close,high,low,high[1],low[1],close[1]])
changeValue10 = (ts10ltp-ts10pclose)
changePer10 = (changeValue10/ts10pclose)
IPV8 = (indexLTP*s8*changePer10)
// Indicators
var PColor = color.white
var PText = ''
//ATR Input
atr_length = input(14, 'ATR Length')
use_current_close = false
period_index = use_current_close ? 0 : 1
//ATR calc
t1atr = request.security(t1, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t1ATR = math.round(t1atr,2)
t1dtr = request.security(t1,'D', math.round(high - low,2))
t1atrp = math.round(t1dtr/t1atr * 100)

t2atr = request.security(t2, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t2ATR = math.round(t2atr,2)
t2dtr = request.security(t2,'D', math.round(high - low,2))
t2atrp = math.round(t2dtr/t2atr * 100)

t3atr = request.security(t3, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t3ATR = math.round(t3atr,2)
t3dtr = request.security(t3,'D', math.round(high - low,2))
t3atrp = math.round(t3dtr/t3atr * 100)

t4atr = request.security(t4, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t4ATR = math.round(t4atr,2)
t4dtr = request.security(t4,'D', math.round(high - low,2))
t4atrp = math.round(t4dtr/t4atr * 100)

t5atr = request.security(t5, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t5ATR = math.round(t5atr,2)
t5dtr = request.security(t5,'D', math.round(high - low,2))
t5atrp = math.round(t5dtr/t5atr * 100)

t6atr = request.security(t6, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t6ATR = math.round(t6atr,2)
t6dtr = request.security(t6,'D', math.round(high - low,2))
t6atrp = math.round(t6dtr/t6atr * 100)

t7atr = request.security(t7, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t7ATR = math.round(t7atr,2)
t7dtr = request.security(t7,'D', math.round(high - low,2))
t7atrp = math.round(t7dtr/t7atr * 100)

t8atr = request.security(t8, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t8ATR = math.round(t8atr,2)
t8dtr = request.security(t8,'D', math.round(high - low,2))
t8atrp = math.round(t8dtr/t8atr * 100)

t9atr = request.security(t9, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t9ATR = math.round(t9atr,2)
t9dtr = request.security(t9,'D', math.round(high - low,2))
t9atrp = math.round(t9dtr/t9atr * 100)

t10atr = request.security(t10, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
t10ATR = math.round(t10atr,2)
t10dtr = request.security(t10,'D', math.round(high - low,2))
t10atrp = math.round(t10dtr/t10atr * 100)

//EMA Cloud
EMA = input.color(color.black)
len = input.int(200, minval=1, title=" EMA Length")
src = close
ema = ta.ema(src, len)
tema=plot(ema, title="EMA", color=EMA, linewidth=1)

FEMA = input.color(color.aqua,title="Fast EMA",group='EMA Cloud')
len1 = input.int(5, minval=1, title=" Fast EMA Length",group='EMA Cloud')
src1 = close
ema1 = ta.ema(src1, len1)
fema1=plot(ema1, title="Fast EMA", color=FEMA, linewidth=1)

SEMA = input.color(color.blue,title="Slow EMA",group='EMA Cloud')
len2 = input.int(21, minval=1, title=" Slow EMA Length",group='EMA Cloud')
src2 = close
ema2 = ta.ema(src2, len2)
fema2=plot(ema2, title="Slow EMA", color=SEMA, linewidth=1)

Bull = ema1 > ema2
Bear = ema1 < ema2
cloud = Bull ? input.color(color.new(color.green,85),"Bullish",group='EMA Cloud') : Bear ? input.color(color.new(color.red,85),"Bearish",group='EMA Cloud') : na
fill(fema1,fema2, color = cloud)

//ADR side of script below
text_ADR1_high = 'ADR1 Upper'
text_ADR2_high = 'ADR2 Upper'
text_ADR1_low = 'ADR1 Lower'
text_ADR2_low = 'ADR2 Lower'
//***Start of Inputs
var labels_enabled = input.bool(defval=true, title='Show labels')
var adr_1 = input.int(title='ADR 1 Period', defval = 10, minval = 1, group='ADR')
var adr_2 = input.int(title='ADR 2 Period', defval = 5, minval = 1, group='ADR')
var color_ADR1_high = input.color(defval=color.new(color.red  ,0), title=text_ADR1_high, group='ADR')
var color_ADR2_high = input.color(defval=color.new(color.red,0), title=text_ADR2_high, group='ADR')
var color_ADR1_low = input.color(defval=color.new(color.green  ,0),   title=text_ADR1_low, group='ADR')
var color_ADR2_low = input.color(defval=color.new(color.green,0),  title=text_ADR2_low, group='ADR')
adrUppercolorfill = input.color(color.red, "Upper Zone Fill",group='ADR',tooltip="Color of zone between Upper Adr 1 and 2")
adrlowercolorfill = input.color(color.green, "Lower Zone Fill",group='ADR',tooltip="Color of zone between Lower Adr 1 and 2")
var plot_history = input.bool(defval=true, group='ADR',title='Historical levels')
//***Start of local functions definiton***
draw_line(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) =>
    dline = line.new(x1=_x1, y1=_y1, x2=_x2, y2=_y2, xloc=_xloc, extend=_extend, color=_color, style=_style, width=_width)
    line.delete(dline[1])

//If security is futures - replace the ticker with continuous contract
tickerid_func() =>
    tickerid = syminfo.tickerid
    if syminfo.type == 'futures'
        tickerid := syminfo.root + '1!'

//Function to calculate ADR levels
//Parameters:
//  * lengthInput - ADR period
//  * hi_low - true-->High, else-->Low 
adr_func(lengthInput,hi_low) =>
    float result = 0
    float adr = 0
    open_ = request.security(tickerid_func(), "D", open, barmerge.gaps_off, barmerge.lookahead_on)
	adr_High = request.security(tickerid_func(), "D", ta.sma(high[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on)
    adr_Low = request.security(tickerid_func(), "D", ta.sma(low[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on)
    adr := (adr_High - adr_Low)
    
    if hi_low//High
        result := adr/2 + open_
    else    //Low
        result := open_ - adr/2    

transp_func() =>
    transp_0 = 0

//***End of local functions definiton***
//***Start of getting data  
start_time = request.security(tickerid_func(), "D", time_close[1],barmerge.gaps_off,barmerge.lookahead_on)
adr1_high = adr_func(adr_1,true)
adr1_low = adr_func(adr_1,false)
adr2_high = adr_func(adr_2,true)
adr2_low = adr_func(adr_2,false)
//***End of getting data
float _adr1_high = na
float _adr1_low = na
float _adr2_high = na
float _adr2_low = na
var show_chart = false

if timeframe.isintraday
    show_chart := true

//Plot all days
if show_chart and plot_history
    _adr1_high := adr1_high
    _adr1_low  := adr1_low
    _adr2_high := adr2_high
    _adr2_low  := adr2_low

ADR1H = plot(_adr1_high, title=text_ADR1_high, color=color_ADR1_high, style=plot.style_circles,linewidth = 1)
ADR2H = plot(_adr2_high, title=text_ADR2_high, color=color_ADR2_high, style=plot.style_circles,linewidth = 1)
ADR1L = plot(_adr1_low, title=text_ADR1_low, color=color_ADR1_low, style=plot.style_circles,linewidth = 1)
ADR2L = plot(_adr2_low, title=text_ADR2_low, color=color_ADR2_low, style=plot.style_circles,linewidth = 1)
fill(ADR1H,ADR2H,color.new(adrUppercolorfill,80))
fill(ADR1L,ADR2L,color.new(adrlowercolorfill,80))

if show_chart and not plot_history
    draw_line1 = line.new(start_time, adr1_high, time, adr1_high, xloc.bar_time, extend.none, color_ADR1_high, line.style_dotted, 2)
    line.delete(draw_line1[1])  
    draw_line2 = line.new(start_time, adr2_high, time, adr2_high, xloc.bar_time, extend.none, color_ADR2_high, line.style_dotted, 2)
    line.delete(draw_line2[1])   
    draw_line3 = line.new(start_time, adr1_low, time, adr1_low, xloc.bar_time, extend.none, color_ADR1_low, line.style_dotted, 2)
    line.delete(draw_line3[1])
    draw_line4 = line.new(start_time, adr2_low, time, adr2_low, xloc.bar_time, extend.none, color_ADR2_low, line.style_dotted, 2)  
    line.delete(draw_line4[1]) 
    linefill.new(draw_line1, draw_line2, color.new(adrUppercolorfill,80))
    linefill.new(draw_line3, draw_line4, color.new(adrlowercolorfill, 80))

// PDH / PDL
PHPL = input(title='PDH/PDL', defval=true,group='pivot')
PH = high
PL = low
PDH = request.security(syminfo.tickerid, 'D', PH[1], barmerge.gaps_off, barmerge.lookahead_on)
PDL = request.security(syminfo.tickerid, 'D', PL[1], barmerge.gaps_off, barmerge.lookahead_on)
PDHColour = PDH != PDH[1] ? na : color.black
PDLColour = PDL != PDL[1] ? na : color.black
plot(PHPL ? PDH : na, title='PDH', color=PDHColour, style=plot.style_line, linewidth=2)
plot(PHPL ? PDL : na, title='PDL', color=PDLColour, style=plot.style_line, linewidth=2)

// Table
// Table Position & Size
var table_position = dash_loc == 'Top Right' ? position.top_right :
  dash_loc == 'Bottom Right' ? position.bottom_right :
  dash_loc == 'Middle Right' ? position.middle_right :
  dash_loc == 'Top Left' ? position.top_left : position.bottom_left
var table_text_size = text_size == 'Small' ? size.small : size.normal
var t = table.new(table_position,11,math.abs(max-min)+2,
  frame_color=color.new(color.gray,0),
  frame_width=1,
  border_color=color.new(#000000,0),
  border_width=1)
// Table Column & Rows
if (barstate.islast)
// Table Main Column Headers
    table.cell(t,1,0,_Index == 'BankNifty' ? 'tradeblinks - BankNifty':'tradeblinks - Nifty',text_color=color.aqua,text_size=size.normal,bgcolor=color.new(color.blue,cell_transp))
    table.merge_cells(t,1,0,9,0)
    table.cell(t,1,1,'Symbol',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,1,'LTP',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,3,1,' D High',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,4,1,'D Low',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,5,1,'I.Points',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,6,1,'PH-PL',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,7,1,'ATR',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,8,1,'DTR',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,9,1,'DTR %',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))

// Display NIFTY/VIX
    table.cell(t,1,2, str.replace_all(t1, 'NSE:', ''), text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,2, str.tostring(ts1ltp, '#.##') ,text_color=color.new(ts1ltp >= ts1pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts1ltp >= ts1pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,2, str.tostring(ts1high, '#.##'),text_color=color.new(ts1high >= ts1pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts1high >= ts1pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,2, str.tostring(ts1low, '#.##') ,text_color=color.new(ts1low >= ts1pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts1low >= ts1pclose ? cell_up : cell_dn ,cell_transp))
    if ts1ltp > ts1PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts1ltp < ts1PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts1ltp < ts1PDH and ts1ltp > ts1PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,5,2, str.tostring(ts1Chng, '#.##'),text_color=color.new(ts1Chng >= 0 ? cell_up : cell_dn,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,6,2, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,2, str.tostring(t1ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,2, str.tostring(t1dtr, '#.##'),text_color=color.new(t1atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t1atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,2, str.tostring(t1atrp, '#.##') + "%",text_color=color.new(t1atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t1atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
// Display BANKNIFTY/NIFTY
    table.cell(t,1,3, str.replace_all(t2, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,3, str.tostring(ts2ltp, '#.##') ,text_color=color.new(ts2ltp >= ts2pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts2ltp >= ts2pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,3, str.tostring(ts2high, '#.##'),text_color=color.new(ts2high >= ts2pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts2high >= ts2pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,3, str.tostring(ts2low, '#.##'),text_color=color.new(ts2low >= ts2pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts2low >= ts2pclose ? cell_up : cell_dn ,cell_transp))
    if ts2ltp > ts2PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts2ltp < ts2PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts2ltp < ts2PDH and ts2ltp > ts2PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,5,3, str.tostring(ts2Chng, '#.##'),text_color=color.new(ts2Chng >= 0 ? cell_up : cell_dn,0),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp))
    table.cell(t,6,3, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,3, str.tostring(t2ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,3, str.tostring(t2dtr, '#.##'),text_color=color.new(t2atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t2atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,3, str.tostring(t2atrp, '#.##') + "%",text_color=color.new(t2atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t2atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
// Display S1
    table.cell(t,1,4, str.replace_all(t3, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,4, str.tostring(ts3ltp, '#.##') ,text_color=color.new(ts3ltp >= ts3pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts3ltp >= ts3pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,4, str.tostring(ts3high, '#.##'),text_color=color.new(ts3high >= ts3pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts3high >= ts3pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,4, str.tostring(ts3low, '#.##') ,text_color=color.new(ts3low >= ts3pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts3low >= ts3pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,5,4, str.tostring(IPV1, '#.##'),text_color=color.new(IPV1 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV1 > 0 ? cell_up : cell_dn ,cell_transp))
    if ts3ltp > ts3PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts3ltp < ts3PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts3ltp < ts3PDH and ts3ltp > ts3PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,6,4, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,4, str.tostring(t3ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,4, str.tostring(t3dtr, '#.##'),text_color=color.new(t3atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t3atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,4, str.tostring(t3atrp, '#.##') + "%",text_color=color.new(t3atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t3atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
// Display S2
    table.cell(t,1,5, str.replace_all(t4, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,5, str.tostring(ts4ltp, '#.##') ,text_color=color.new(ts4ltp >= ts4pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts4ltp >= ts4pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,5, str.tostring(ts4high, '#.##'),text_color=color.new(ts4high >= ts4pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts4high >= ts4pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,5, str.tostring(ts4low, '#.##') ,text_color=color.new(ts4low >= ts4pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts4low >= ts4pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,5,5, str.tostring(IPV2, '#.##'),text_color=color.new(IPV2 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV2 > 0 ? cell_up : cell_dn ,cell_transp))
    if ts4ltp > ts4PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts4ltp < ts4PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts4ltp < ts4PDH and ts4ltp > ts4PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,6,5, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,5, str.tostring(t4ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,5, str.tostring(t4dtr, '#.##'),text_color=color.new(t4atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t4atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,5, str.tostring(t4atrp, '#.##') + "%",text_color=color.new(t4atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t4atrp < 61.8 ? cell_up : cell_dn ,cell_transp))   
// Display S3
    table.cell(t,1,6, str.replace_all(t5, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,6, str.tostring(ts5ltp, '#.##') ,text_color=color.new(ts5ltp >= ts5pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts5ltp >= ts5pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,6, str.tostring(ts5high, '#.##'),text_color=color.new(ts5high >= ts5pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts5high >= ts5pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,6, str.tostring(ts5low, '#.##') ,text_color=color.new(ts5low >= ts5pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts5low >= ts5pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,5,6, str.tostring(IPV3, '#.##'),text_color=color.new(IPV3 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV3 > 0 ? cell_up : cell_dn ,cell_transp))
    if ts5ltp > ts5PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts5ltp < ts5PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts5ltp < ts5PDH and ts5ltp > ts5PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,6,6, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,6, str.tostring(t5ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,6, str.tostring(t5dtr, '#.##'),text_color=color.new(t5atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t5atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,6, str.tostring(t5atrp, '#.##') + "%",text_color=color.new(t5atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t5atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
// Display S4
    table.cell(t,1,7, str.replace_all(t6, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,7, str.tostring(ts6ltp, '#.##') ,text_color=color.new(ts6ltp >= ts6pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts6ltp >= ts6pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,7, str.tostring(ts6high, '#.##'),text_color=color.new(ts6high >= ts6pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts6high >= ts6pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,7, str.tostring(ts6low, '#.##') ,text_color=color.new(ts6low >= ts6pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts6low >= ts6pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,5,7, str.tostring(IPV4, '#.##'),text_color=color.new(IPV4 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV4 > 0 ? cell_up : cell_dn ,cell_transp))
    if ts6ltp > ts6PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts6ltp < ts6PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts6ltp < ts6PDH and ts6ltp > ts6PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,6,7, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,7, str.tostring(t6ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,7, str.tostring(t6dtr, '#.##'),text_color=color.new(t6atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t6atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,7, str.tostring(t6atrp, '#.##') + "%",text_color=color.new(t6atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t6atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
// Display S5
    table.cell(t,1,8, str.replace_all(t7, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,8, str.tostring(ts7ltp, '#.##') ,text_color=color.new(ts7ltp >= ts7pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts7ltp >= ts7pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,8, str.tostring(ts7high, '#.##'),text_color=color.new(ts7high >= ts7pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts7high >= ts7pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,8, str.tostring(ts7low, '#.##') ,text_color=color.new(ts7low >= ts7pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts7low >= ts7pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,5,8, str.tostring(IPV5, '#.##'),text_color=color.new(IPV5 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV5 > 0 ? cell_up : cell_dn ,cell_transp))
    if ts7ltp > ts7PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts7ltp < ts7PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts7ltp < ts7PDH and ts7ltp > ts7PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,6,8, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,8, str.tostring(t7ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,8, str.tostring(t7dtr, '#.##'),text_color=color.new(t7atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t7atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,8, str.tostring(t7atrp, '#.##') + "%",text_color=color.new(t7atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t7atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
// Display S6
    table.cell(t,1,9, str.replace_all(t8, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,9, str.tostring(ts8ltp, '#.##') ,text_color=color.new(ts8ltp >= ts8pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts8ltp >= ts8pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,9, str.tostring(ts8high, '#.##'),text_color=color.new(ts8high >= ts8pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts8high >= ts8pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,9, str.tostring(ts8low, '#.##') ,text_color=color.new(ts8low >= ts8pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts8low >= ts8pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,5,9, str.tostring(IPV6, '#.##'),text_color=color.new(IPV6 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV6 > 0 ? cell_up : cell_dn ,cell_transp))
    if ts8ltp > ts8PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts8ltp < ts8PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts8ltp < ts8PDH and ts8ltp > ts8PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,6,9, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,9, str.tostring(t8ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,9, str.tostring(t8dtr, '#.##'),text_color=color.new(t8atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t8atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,9, str.tostring(t8atrp, '#.##') + "%",text_color=color.new(t8atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t8atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
// Display S7
    table.cell(t,1,10, str.replace_all(t9, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,10, str.tostring(ts9ltp, '#.##') ,text_color=color.new(ts9ltp >= ts9pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts9ltp >= ts9pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,10, str.tostring(ts9high, '#.##'),text_color=color.new(ts9high >= ts9pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts9high >= ts9pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,10, str.tostring(ts9low, '#.##') ,text_color=color.new(ts9low >= ts9pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts9low >= ts9pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,5,10, str.tostring(IPV7, '#.##'),text_color=color.new(IPV7 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV7 > 0 ? cell_up : cell_dn ,cell_transp))
    if ts9ltp > ts9PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts9ltp < ts9PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts9ltp < ts9PDH and ts9ltp > ts9PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,6,10, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,10, str.tostring(t9ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,10, str.tostring(t9dtr, '#.##'),text_color=color.new(t9atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t9atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,10, str.tostring(t9atrp, '#.##') + "%",text_color=color.new(t9atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t9atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
// Display S8
    table.cell(t,1,11, str.replace_all(t10, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp))
    table.cell(t,2,11, str.tostring(ts10ltp, '#.##') ,text_color=color.new(ts10ltp >= ts10pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts10ltp >= ts10pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,3,11, str.tostring(ts10high, '#.##'),text_color=color.new(ts10high >= ts10pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts10high >= ts10pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,4,11, str.tostring(ts10low, '#.##') ,text_color=color.new(ts10low >= ts10pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts10low >= ts10pclose ? cell_up : cell_dn ,cell_transp))
    table.cell(t,5,11, str.tostring(IPV8, '#.##'),text_color=color.new(IPV8 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV8 > 0 ? cell_up : cell_dn ,cell_transp))
    if ts10ltp > ts10PDH
        PColor:= color.new( cell_up ,cell_transp)
        PText:= '+ PH'
    else if ts10ltp < ts10PDL
        PColor:= color.new( cell_dn ,cell_transp)
        PText:= '- PL'
    else if ts10ltp < ts10PDH and ts10ltp > ts10PDL
        PColor:= color.new( cell_neutral ,cell_transp)
        PText:= 'PH-PL'
    table.cell(t,6,11, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp))
    table.cell(t,7,11, str.tostring(t10ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp))
    table.cell(t,8,11, str.tostring(t10dtr, '#.##'),text_color=color.new(t10atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t10atrp < 61.8 ? cell_up : cell_dn ,cell_transp))
    table.cell(t,9,11, str.tostring(t10atrp, '#.##') + "%",text_color=color.new(t10atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t10atrp < 61.8 ? cell_up : cell_dn ,cell_transp))

// END //