Statistics Table
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jadeja_rajdeep

//@version=5
indicator("Statistics Table",overlay=true)

firstema_length=input.int(13,"First Ema Length",1,step = 1)
secondema_length=input.int(21,"Second Ema Length",1,step = 1)
thirdema_length=input.int(50,"Third Ema Length",1,step = 1)
fourthema_length=input.int(200,"Fourth Ema Length",1,step = 1)

atr_length=input.int(21,"ATR/ADR Length",1,step = 1)
vud_length=input.int(21,"Volume U/D Ratio Length",1,step = 1)
pp_length=input.int(21,"Volume Pocket Pivot Point Length",1,step = 1)

firstrs_length=input.int(21,"First RS Length",1,step = 1)
secondrs_length=input.int(42,"Second RS Length",1,step = 1)
thirdrs_length=input.int(63,"Third RS Length",1,step = 1)
fourthrs_length=input.int(126,"Fourth RS Length",1,step = 1)

firstrsi_length=input.int(14,"First RSI Length",1,step = 1,inline = 'firstrsi')
firstrsi_timeframe=input.string('60',"First RSI TimeFrame",inline = 'firstrsi',tooltip = 'The unit is represented by a single letter, with no letter used for minutes: “S” for seconds, “D” for days, “W” for weeks and “M” for months.')
secondrsi_length=input.int(14,"Second RSI Length",1,step = 1,inline = 'secondrsi')
secondrsi_timeframe=input.string('1D',"Second RSI TimeFrame",inline = 'secondrsi')
thirdrsi_length=input.int(14,"Third RSI Length",1,step = 1,inline = 'thirdrsi')
thirdrsi_timeframe=input.string('1W',"Third RSI TimeFrame",inline = 'thirdrsi')
fourthrsi_length=input.int(12,"Fourth RSI Length",1,step = 1,inline = 'fourthrsi')
fourthrsi_timeframe=input.string('1M',"Fourth RSI TimeFrame",inline = 'fourthrsi')

firstcci_length=input.int(14,"First CCI Length",1,step = 1,inline = 'firstcci')
firstcci_timeframe=input.string('60',"First CCI TimeFrame",inline = 'firstcci',tooltip = 'The unit is represented by a single letter, with no letter used for minutes: “S” for seconds, “D” for days, “W” for weeks and “M” for months.')
secondcci_length=input.int(14,"Second CCI Length",1,step = 1,inline = 'secondcci')
secondcci_timeframe=input.string('1D',"Second CCI TimeFrame",inline = 'secondcci')
thirdcci_length=input.int(14,"Third CCI Length",1,step = 1,inline = 'thirdcci')
thirdcci_timeframe=input.string('1W',"Third CCI TimeFrame",inline = 'thirdcci')
fourthcci_length=input.int(12,"Fourth CCI Length",1,step = 1,inline = 'fourthcci')
fourthcci_timeframe=input.string('1M',"Fourth CCI TimeFrame",inline = 'fourthcci')

firstadx_length=input.int(14,"First ADX Length",1,step = 1,inline = 'firstadx')
firstadx_timeframe=input.string('60',"First ADX TimeFrame",inline = 'firstadx',tooltip = 'The unit is represented by a single letter, with no letter used for minutes: “S” for seconds, “D” for days, “W” for weeks and “M” for months.')
firstadx_smoothing_length=input.int(7,"First ADX Smoothing Length",1,step = 1,inline = 'firstadx')

secondadx_length=input.int(14,"Second ADX Length",1,step = 1,inline = 'secondadx')
secondadx_timeframe=input.string('1D',"Second ADX TimeFrame",inline = 'secondadx')
secondadx_smoothing_length=input.int(7,"Second ADX Smoothing Length",1,step = 1,inline = 'secondadx')

thirdadx_length=input.int(14,"Third ADX Length",1,step = 1,inline = 'thirdadx')
thirdadx_timeframe=input.string('1W',"Third ADX TimeFrame",inline = 'thirdadx')
thirdadx_smoothing_length=input.int(7,"Third ADX Smoothing Length",1,step = 1,inline = 'thirdadx')

fourthadx_length=input.int(12,"Fourth ADX Length",1,step = 1,inline = 'fourthadx')
fourthadx_timeframe=input.string('1M',"Fourth ADX TimeFrame",inline = 'fourthadx')
fourthadx_smoothing_length=input.int(3,"Fourth ADX Smoothing Length",1,step = 1,inline = 'fourthadx')

display_diff_ema_first=input.bool(true,"Display close difference from first ema",group = "Display")
display_diff_ema_second=input.bool(true,"Display close difference from second ema",group = "Display")
display_diff_ema_third=input.bool(true,"Display close difference from third ema",group = "Display")
display_diff_ema_fourth=input.bool(true,"Display close difference from fourth ema",group = "Display")

display_diff_ema_first_second=input.bool(true,"Display difference between first and second ema",group = "Display")
display_diff_ema_second_third=input.bool(true,"Display difference between second and third ema",group = "Display")
display_diff_ema_first_third=input.bool(true,"Display difference between first and third ema",group = "Display")

display_ud_ratio=input.bool(true,"Display volume up down ratio",group = "Display")
display_atr_adr=input.bool(true,"Display ATR/ADR %",group = "Display")
display_vppc=input.bool(true,"Display volume pocket pivot count",group = "Display")

display_dcr=input.bool(true,"Display daily closing range",group = "Display")
display_wcr=input.bool(true,"Display weekly closing range",group = "Display")

display_52week_high=input.bool(true,"Display close difference from 52week high",group = "Display")
display_52week_low=input.bool(true,"Display close difference from 52week low",group = "Display")

display_ath=input.bool(true,"Display close difference from All time high",group = "Display")
display_atl=input.bool(true,"Display close difference from All time low",group = "Display")

display_rsline_above_ema_first=input.bool(true,"Display rs line above or below first rs ema",group = "Display")
display_rsline_above_ema_second=input.bool(true,"Display rs line above or below second rs ema",group = "Display")
display_rsline_above_ema_third=input.bool(true,"Display rs line above or below third rs ema",group = "Display")
display_rsline_above_ema_fourth=input.bool(true,"Display rs line above or below fourth rs ema",group = "Display")

display_rs_value_first=input.bool(true,"Display first rs value",group = "Display")
display_rs_value_second=input.bool(true,"Display second rs value",group = "Display")
display_rs_value_third=input.bool(true,"Display third rs value",group = "Display")
display_rs_value_fourth=input.bool(true,"Display fourth rs value",group = "Display")

display_diff_change_first_first=input.bool(true,"Display difference between previous first rs length days change % and current first rs length days change %",group = "Display")
display_diff_change_second_second=input.bool(true,"Display difference between previous second rs length days change % and current second rs length days change %",group = "Display")
display_diff_change_third_third=input.bool(true,"Display difference between previous third rs length days change % and current third rs length days change %",group = "Display")

display_first_rsi=input.bool(true,"Display first rsi value",group = "Display")
display_second_rsi=input.bool(true,"Display second rsi value",group = "Display")
display_third_rsi=input.bool(true,"Display third rsi value",group = "Display")
display_fourth_rsi=input.bool(true,"Display fourth rsi value",group = "Display")

display_first_cci=input.bool(true,"Display first cci value",group = "Display")
display_second_cci=input.bool(true,"Display second cci value",group = "Display")
display_third_cci=input.bool(true,"Display third cci value",group = "Display")
display_fourth_cci=input.bool(true,"Display fourth cci value",group = "Display")

display_first_adx=input.bool(true,"Display first adx value",group = "Display")
display_second_adx=input.bool(true,"Display second adx value",group = "Display")
display_third_adx=input.bool(true,"Display third adx value",group = "Display")
display_fourth_adx=input.bool(true,"Display fourth adx value",group = "Display")

color_regular_value=input.color(color.blue,'Regular Value Color',group = "Color")
color_positive_value=input.color(color.green,'Positive Value Color',group = "Color")
color_negative_value=input.color(color.red,'Negative Value Color',group = "Color")
color_label=input.color(color.gray,'Label Color',group = "Color")

font_size=input.string(size.small,"Font Size",options = [size.normal,size.small,size.tiny])
table_postion=input.string(position.top_right,"Table Position",options = [position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right])

check_first_ema_diff=input.float(0,"Positive First EMA Diff",group = "Condition Check Value")
check_second_ema_diff=input.float(0,"Positive Second EMA Diff",group = "Condition Check Value")
check_third_ema_diff=input.float(0,"Positive Third EMA Diff",group = "Condition Check Value")
check_fourth_ema_diff=input.float(0,"Positive Fourth EMA Diff",group = "Condition Check Value")

check_first_second_ema_diff=input.float(0,"Positive First - Second EMA Diff",group = "Condition Check Value")
check_second_third_ema_diff=input.float(0,"Positive Second - Third EMA Diff",group = "Condition Check Value")
check_first_third_ema_diff=input.float(0,"Positive First - Third EMA Diff",group = "Condition Check Value")

check_ud_ratio=input.float(2.5,"Positive V U/D RATIO",group = "Condition Check Value")
check_pocket_pivot=input.float(1,"Positive Pocket Pivot Point",group = "Condition Check Value")
check_dcr=input.float(50,"Positive Daily Closing Range",group = "Condition Check Value")
check_wcr=input.float(50,"Positive Weekly Closing Range",group = "Condition Check Value")
check_52wkhigh=input.float(-21,"Positive From 52 Week High",group = "Condition Check Value")
check_52wklow=input.float(30,"Positive From 52 Week Low",group = "Condition Check Value")
check_allhigh=input.float(-50,"Positive From All Time High",group = "Condition Check Value")
check_alllow=input.float(50,"Positive From All Time Low",group = "Condition Check Value")

check_rsi_first=input.float(50,"Positive First RSI",group = "Condition Check Value")
check_rsi_second=input.float(50,"Positive Second RSI",group = "Condition Check Value")
check_rsi_third=input.float(50,"Positive Third RSI",group = "Condition Check Value")
check_rsi_fourth=input.float(50,"Positive Fourth RSI",group = "Condition Check Value")

check_cci_first=input.float(50,"Positive First CCI",group = "Condition Check Value")
check_cci_second=input.float(50,"Positive Second CCI",group = "Condition Check Value")
check_cci_third=input.float(50,"Positive Third CCI",group = "Condition Check Value")
check_cci_fourth=input.float(50,"Positive Fourth CCI",group = "Condition Check Value")

check_adx_first=input.float(25,"Positive First ADX",group = "Condition Check Value")
check_adx_second=input.float(25,"Positive Second ADX",group = "Condition Check Value")
check_adx_third=input.float(25,"Positive Third ADX",group = "Condition Check Value")
check_adx_fourth=input.float(25,"Positive Fourth ADX",group = "Condition Check Value")

ema13=ta.ema(close,firstema_length)
ema21=ta.ema(close,secondema_length)
ema50=ta.ema(close,thirdema_length)
ema200=ta.ema(close,fourthema_length)

whigh=request.security(syminfo.tickerid,"1W",high)
wlow=request.security(syminfo.tickerid,"1W",low)
wclose=request.security(syminfo.tickerid,"1W",close)

atr23=ta.atr(atr_length)

whigh52=request.security(syminfo.tickerid,"1W",ta.highest(high,52))
wlow52=request.security(syminfo.tickerid,"1W",ta.lowest(low,52))

ahigh=ta.highest(high,(last_bar_index + 1))
alow=ta.lowest(low,(last_bar_index + 1))

//displaying rs21 and rs50 line in table
i_nifty50 = input.symbol("NIFTY", "Symbol")
NIFTY50 = request.security(i_nifty50, 'D', close)
NIFTY50_21 = request.security(i_nifty50, 'D', close[firstrs_length - 1])
NIFTY50_42 = request.security(i_nifty50, 'D', close[secondrs_length - 1])
NIFTY50_63 = request.security(i_nifty50, 'D', close[thirdrs_length - 1])
NIFTY50_126 = request.security(i_nifty50, 'D', close[fourthrs_length - 1])

rsline=(close/NIFTY50)
rsline21=ta.ema(rsline,firstrs_length)
rsline42=ta.ema(rsline,secondrs_length)
rsline63=ta.ema(rsline,thirdrs_length)
rsline126=ta.ema(rsline,fourthrs_length)

rs21=close / close[firstrs_length - 1]
rs42=close / close[secondrs_length - 1]
rs63=close / close[thirdrs_length - 1]
rs126=close / close[fourthrs_length - 1]

rs21_index=NIFTY50 / NIFTY50_21
rs42_index=NIFTY50 / NIFTY50_42
rs63_index=NIFTY50 / NIFTY50_63
rs126_index=NIFTY50 / NIFTY50_126

rs_21=rs21/rs21_index
rs_42=rs42/rs42_index
rs_63=rs63/rs63_index
rs_126=rs126/rs126_index


//RSI CODE START
rsi1=request.security(syminfo.tickerid,firstrsi_timeframe,ta.rsi(close,firstrsi_length))
rsi2=request.security(syminfo.tickerid,secondrsi_timeframe,ta.rsi(close,secondrsi_length))
rsi3=request.security(syminfo.tickerid,thirdrsi_timeframe,ta.rsi(close,thirdrsi_length))
rsi4=request.security(syminfo.tickerid,fourthrsi_timeframe,ta.rsi(close,fourthrsi_length))
//RSI CODE END

//CCI CODE START
cci1=request.security(syminfo.tickerid,firstcci_timeframe,ta.cci(hlc3,firstcci_length))
cci2=request.security(syminfo.tickerid,secondcci_timeframe,ta.cci(hlc3,secondcci_length))
cci3=request.security(syminfo.tickerid,thirdcci_timeframe,ta.cci(hlc3,thirdcci_length))
cci4=request.security(syminfo.tickerid,fourthcci_timeframe,ta.cci(hlc3,fourthcci_length))
//CCI CODE END

//ADX CODE START
[diplus1, diminus1, adx1]=request.security(syminfo.tickerid,firstadx_timeframe,ta.dmi(firstadx_length,firstadx_smoothing_length))
[diplus2, diminus2, adx2]=request.security(syminfo.tickerid,secondadx_timeframe,ta.dmi(secondadx_length,secondadx_smoothing_length))
[diplus3, diminus3, adx3]=request.security(syminfo.tickerid,thirdadx_timeframe,ta.dmi(thirdadx_length,thirdadx_smoothing_length))
[diplus4, diminus4, adx4]=request.security(syminfo.tickerid,fourthadx_timeframe,ta.dmi(fourthadx_length,fourthadx_smoothing_length))
//CCI CODE END

if barstate.islast
    ema13_close_diff=((close - ema13) * 100) / ema13
    ema13_close_diff_color=(ema13_close_diff >= check_first_ema_diff ? color_positive_value : color_negative_value)

    ema21_close_diff=((close - ema21) * 100) / ema21
    ema21_close_diff_color=(ema21_close_diff >= check_second_ema_diff ? color_positive_value : color_negative_value)

    ema50_close_diff=((close - ema50) * 100) / ema50
    ema50_close_diff_color=(ema50_close_diff >= check_third_ema_diff ? color_positive_value : color_negative_value)

    ema200_close_diff=((close - ema200) * 100) / ema200
    ema200_close_diff_color=(ema200_close_diff >= check_fourth_ema_diff ? color_positive_value : color_negative_value)

    ema_13_21=((ema13 - ema21) * 100) / ema21
    ema_13_21_color=(ema_13_21 >= check_first_second_ema_diff ? color_positive_value : color_negative_value)
    ema_21_50=((ema21 - ema50) * 100) / ema50
    ema_21_50_color=(ema_21_50 >= check_second_third_ema_diff ? color_positive_value : color_negative_value)
    ema_13_50=((ema13 - ema50) * 100) / ema50
    ema_13_50_color=(ema_13_50 >= check_first_third_ema_diff ? color_positive_value : color_negative_value)

    up = 0
    down = 0
    for i = 0 to (vud_length - 1)
        if (close[i] > close[i + 1])
            up := up + int(volume[i])
        else
            down := down + int(volume[i])
    ud_ratio=up/down
    ud_ratio_color=(ud_ratio >= check_ud_ratio ? color_positive_value : color_negative_value)

    pocketvol=0.0
    pocket_pivot_count=0
    for i = 0 to (pp_length - 1)
        pocketvol :=0.0
        for j = 1 to 10
            if (close[i + 1] < close[i + 2] and (volume[i + 1] > pocketvol or pocketvol == 0.0))
                pocketvol := volume[i + 1]
        
        if (volume[i] > pocketvol and close[i] >= open[i] and close[i] >= close[i + 1])
            pocket_pivot_count := pocket_pivot_count + 1

    pocket_pivot_count_colour=(pocket_pivot_count > check_pocket_pivot ? color_positive_value : color_negative_value)

    adr23=(atr23 / close) * 100

    dcr=((close - low) / (high - low)) * 100
    dcr_color=(dcr >= check_dcr ? color_positive_value : color_negative_value)
    
    wcr=((wclose - wlow) / (whigh - wlow)) * 100
    wcr_color=(wcr >= check_wcr ? color_positive_value : color_negative_value)

    from52whigh=((close - whigh52) * 100) / whigh52
    from52whigh_color=(from52whigh >= check_52wkhigh ? color_positive_value : color_negative_value)

    from52wlow=((close - wlow52) * 100) / wlow52
    from52wlow_color=(from52wlow >= check_52wklow ? color_positive_value : color_negative_value)
    
    fromahigh=((close - ahigh) * 100) / ahigh
    fromalow=((close - alow) * 100) / alow

    fromahigh_color=(fromahigh >= check_allhigh ? color_positive_value : color_negative_value)
    fromalow_color=(fromalow >= check_alllow ? color_positive_value : color_negative_value)

    rsline21text=(rsline >= rsline21 ? "Yes" : "No")
    rsline42text=(rsline >= rsline42 ? "Yes" : "No")
    rsline63text=(rsline >= rsline63 ? "Yes" : "No")
    rsline126text=(rsline >= rsline126 ? "Yes" : "No")
    
    rsline21textcolor=(rsline >= rsline21 ? color_positive_value : color_negative_value)
    rsline42textcolor=(rsline >= rsline42 ? color_positive_value : color_negative_value)
    rsline63textcolor=(rsline >= rsline63 ? color_positive_value : color_negative_value)
    rsline126textcolor=(rsline >= rsline126 ? color_positive_value : color_negative_value)

    rs21textcolor=(rs_21 >= 1 ? color_positive_value : color_negative_value)
    rs42textcolor=(rs_42 >= 1 ? color_positive_value : color_negative_value)
    rs63textcolor=(rs_63 >= 1 ? color_positive_value : color_negative_value)
    rs126textcolor=(rs_126 >= 1 ? color_positive_value : color_negative_value)

    chng_21=(((close - close[firstrs_length - 1])*100)/close[firstrs_length - 1]) - math.abs(((close[firstrs_length] - close[(firstrs_length * 2) - 1])*100)/close[(firstrs_length * 2) - 1])
    chng_42=(((close - close[secondrs_length - 1])*100)/close[secondrs_length - 1]) - math.abs(((close[secondrs_length] - close[(secondrs_length * 2) - 1])*100)/close[(secondrs_length * 2) - 1])
    chng_63=(((close - close[thirdrs_length - 1])*100)/close[thirdrs_length - 1]) - math.abs(((close[thirdrs_length] - close[(thirdrs_length * 2) - 1])*100)/close[(thirdrs_length * 2) - 1])

    chng_21textcolor=(chng_21 > 0 ? color_positive_value : color_negative_value)
    chng_42textcolor=(chng_42 > 0 ? color_positive_value : color_negative_value)
    chng_63textcolor=(chng_63 > 0 ? color_positive_value : color_negative_value)

    var rstable = table.new(position = table_postion ,columns = 2, rows = 39)

    var table_row=0

    if(display_diff_ema_first==true)
        table.cell(rstable,0,table_row,"EMA"+str.tostring(firstema_length) + " %",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(ema13_close_diff,2)),text_color=ema13_close_diff_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_diff_ema_second==true)
        table.cell(rstable,0,table_row,"EMA"+str.tostring(secondema_length) + " %",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(ema21_close_diff,2)),text_color=ema21_close_diff_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_diff_ema_third==true)
        table.cell(rstable,0,table_row,"EMA"+str.tostring(thirdema_length) + " %",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(ema50_close_diff,2)),text_color=ema50_close_diff_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_diff_ema_fourth==true)
        table.cell(rstable,0,table_row,"EMA"+str.tostring(fourthema_length) + " %",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(ema200_close_diff,2)),text_color=ema200_close_diff_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_diff_ema_first_second==true)
        table.cell(rstable,0,table_row,"EMA "+str.tostring(firstema_length)+"/"+str.tostring(secondema_length)+" %",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(ema_13_21,2)),text_color=ema_13_21_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_diff_ema_second_third==true)
        table.cell(rstable,0,table_row,"EMA "+str.tostring(secondema_length)+"/"+str.tostring(thirdema_length)+" %",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(ema_21_50,2)),text_color=ema_21_50_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_diff_ema_first_third==true)
        table.cell(rstable,0,table_row,"EMA "+str.tostring(firstema_length)+"/"+str.tostring(thirdema_length)+" %",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(ema_13_50,2)),text_color=ema_21_50_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_ud_ratio==true)
        table.cell(rstable,0,table_row,"V U/D RATIO "+str.tostring(vud_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(ud_ratio,2)),text_color=ud_ratio_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_atr_adr==true)
        table.cell(rstable,0,table_row,"ADR "+str.tostring(atr_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(adr23,2)),text_color=color_regular_value,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_vppc==true)
        table.cell(rstable,0,table_row,"Pocket PP "+str.tostring(pp_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(pocket_pivot_count,2)),text_color=pocket_pivot_count_colour,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_dcr==true)
        table.cell(rstable,0,table_row,"DCR",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(dcr,2)),text_color=dcr_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_wcr==true)
        table.cell(rstable,0,table_row,"WCR",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(wcr,2)),text_color=wcr_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_52week_high==true)
        table.cell(rstable,0,table_row,"52W High",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(from52whigh,2)),text_color=from52whigh_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_52week_low==true)
        table.cell(rstable,0,table_row,"52W Low",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(from52wlow,2)),text_color=from52wlow_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_ath==true)
        table.cell(rstable,0,table_row,"ATH",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(fromahigh,2)),text_color=fromahigh_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_atl==true)
        table.cell(rstable,0,table_row,"ATL",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(fromalow,2)),text_color=fromalow_color,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_rsline_above_ema_first==true)
        table.cell(rstable,0,table_row,"RsLine > EMA"+str.tostring(firstrs_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,rsline21text,text_color=rsline21textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_rsline_above_ema_second==true)
        table.cell(rstable,0,table_row,"RsLine > EMA"+str.tostring(secondrs_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,rsline42text,text_color=rsline42textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_rsline_above_ema_third==true)
        table.cell(rstable,0,table_row,"RsLine > EMA"+str.tostring(thirdrs_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,rsline63text,text_color=rsline63textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_rsline_above_ema_fourth==true)
        table.cell(rstable,0,table_row,"RsLine > EMA"+str.tostring(fourthrs_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,rsline126text,text_color=rsline126textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_rs_value_first==true)
        table.cell(rstable,0,table_row,"RS"+str.tostring(firstrs_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row, str.tostring(math.round(rs_21,2)) ,text_color=rs21textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_rs_value_second==true)
        table.cell(rstable,0,table_row,"RS"+str.tostring(secondrs_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(rs_42,2)),text_color=rs42textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_rs_value_third==true)
        table.cell(rstable,0,table_row,"RS"+str.tostring(thirdrs_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(rs_63,2)),text_color=rs63textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_rs_value_fourth==true)
        table.cell(rstable,0,table_row,"RS"+str.tostring(fourthrs_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(rs_126,2)),text_color=rs126textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_diff_change_first_first==true)
        table.cell(rstable,0,table_row,str.tostring(firstrs_length)+" Chng Diff",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row, str.tostring(math.round(chng_21,2)) ,text_color=chng_21textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_diff_change_second_second==true)
        table.cell(rstable,0,table_row,str.tostring(secondrs_length)+" Chng Diff",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(chng_42,2)),text_color=chng_42textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_diff_change_third_third==true)
        table.cell(rstable,0,table_row,str.tostring(thirdrs_length)+" Chng Diff",text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(chng_63,2)),text_color=chng_63textcolor,text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_first_rsi==true)
        table.cell(rstable,0,table_row,'RSI '+str.tostring(firstrsi_timeframe)+' '+str.tostring(firstrsi_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(rsi1,2)),text_color=(rsi1 >= check_rsi_first ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_second_rsi==true)
        table.cell(rstable,0,table_row,'RSI '+str.tostring(secondrsi_timeframe)+' '+str.tostring(secondrsi_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(rsi2,2)),text_color=(rsi2 >= check_rsi_second ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_third_rsi==true)
        table.cell(rstable,0,table_row,'RSI '+str.tostring(thirdrsi_timeframe)+' '+str.tostring(thirdrsi_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(rsi3,2)),text_color=(rsi3 >= check_rsi_third ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_fourth_rsi==true)
        table.cell(rstable,0,table_row,'RSI '+str.tostring(fourthrsi_timeframe)+' '+str.tostring(fourthrsi_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(rsi4,2)),text_color=(rsi4 >= check_rsi_fourth ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_first_cci==true)
        table.cell(rstable,0,table_row,'CCI '+str.tostring(firstcci_timeframe)+' '+str.tostring(firstcci_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(cci1,2)),text_color=(cci1 >= check_cci_first ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_second_cci==true)
        table.cell(rstable,0,table_row,'CCI '+str.tostring(secondcci_timeframe)+' '+str.tostring(secondcci_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(cci2,2)),text_color=(cci2 >= check_cci_second ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_third_cci==true)
        table.cell(rstable,0,table_row,'CCI '+str.tostring(thirdcci_timeframe)+' '+str.tostring(thirdcci_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(cci3,2)),text_color=(cci3 >= check_cci_third ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_fourth_cci==true)
        table.cell(rstable,0,table_row,'CCI '+str.tostring(fourthcci_timeframe)+' '+str.tostring(fourthcci_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(cci4,2)),text_color=(cci4 >= check_cci_fourth ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_first_adx==true)
        table.cell(rstable,0,table_row,'ADX '+str.tostring(firstadx_timeframe)+' '+str.tostring(firstadx_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(adx1,2)),text_color=(adx1 >= check_adx_first ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_second_adx==true)
        table.cell(rstable,0,table_row,'ADX '+str.tostring(secondadx_timeframe)+' '+str.tostring(secondadx_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(adx2,2)),text_color=(adx2 >= check_adx_second ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1
    
    if(display_third_adx==true)
        table.cell(rstable,0,table_row,'ADX '+str.tostring(thirdadx_timeframe)+' '+str.tostring(thirdadx_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(adx3,2)),text_color=(adx3 >= check_adx_third ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    if(display_fourth_adx==true)
        table.cell(rstable,0,table_row,'ADX '+str.tostring(fourthadx_timeframe)+' '+str.tostring(fourthadx_length),text_halign = text.align_right,text_size = font_size,text_color = color_label)
        table.cell(rstable,1,table_row,str.tostring(math.round(adx4,2)),text_color=(adx4 >= check_adx_fourth ? color_positive_value : color_negative_value ),text_halign = text.align_left,text_size = font_size)
        table_row := table_row + 1

    