NK Sir's SRT
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © apurvaverma

//@version=5

// Thanks to Nitish Sir for teaching the concept of SRT for Investments
indicator("NK Sir's SRT", overlay = true)

isScripValid = if(syminfo.ticker == "NIFTY")
    1
else
    0
nifty = if(isScripValid)
    close
else
    na

var string GP1 = "SRT Panel"
string  tableYposInput = input.string("top", "SRT Panel Position", inline = "11", options = ["top", "middle", "bottom"], group = GP1)
string  tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"], group = GP1)

var srtTable = table.new(tableYposInput + "_" + tableXposInput, columns = 2, rows = 4, bgcolor = color.white, border_width = 1, frame_color = color.gray, frame_width = 2, border_color = color.gray)

vix = request.security("INDIAVIX", "D", close)
sma = ta.sma(close, 124)
srt = nifty/sma

table.cell(table_id = srtTable, column = 0, row = 0, text = "NIFTY 50", text_color = color.white, bgcolor = color.aqua)
table.cell(table_id = srtTable, column = 0, row = 1, text = "SMA 124", text_color = color.white, bgcolor = color.aqua)
table.cell(table_id = srtTable, column = 0, row = 2, text = "SRT Value", text_color = color.white, bgcolor = color.aqua)
table.cell(table_id = srtTable, column = 0, row = 3, text = "India VIX", text_color = color.white, bgcolor = color.aqua)


table.cell(table_id = srtTable, column = 1, row = 0, text = str.tostring(nifty))
table.cell(table_id = srtTable, column = 1, row = 1, text = str.tostring(sma,"#.##"))
table.cell(table_id = srtTable, column = 1, row = 2, text = str.tostring(srt,"#.##"))
table.cell(table_id = srtTable, column = 1, row = 3, text = str.tostring(vix,"#.##"))
