Alternative to Pinescript table.new() built-in function

 

Hello,

I can't see a 'straight forward' way of creating a table on a chart, in the simplicity that Pinescript offers the table.new() and table.cell() functions - is the easiest solution to create a table using ObjectCreate() and OBJ_TREND?

I'm interested in making a handy strength indicator for MT5 like I have made in Pinescript:


indicator("Currency Strength Table",overlay=true)

lookback_period = input.int(7,"Lookback Period")
timeframe = input.timeframe('D',"Timeframe")

audcad = ta.rsi(request.security("AUDCAD", timeframe, close),lookback_period)
audchf = ta.rsi(request.security("AUDCHF", timeframe, close),lookback_period)
audjpy = ta.rsi(request.security("AUDJPY", timeframe, close),lookback_period)
audnzd = ta.rsi(request.security("AUDNZD", timeframe, close),lookback_period)
audusd = ta.rsi(request.security("AUDUSD", timeframe, close),lookback_period)
cadchf = ta.rsi(request.security("CADCHF", timeframe, close),lookback_period)
cadjpy = ta.rsi(request.security("CADJPY", timeframe, close),lookback_period)
chfjpy = ta.rsi(request.security("CHFJPY", timeframe, close),lookback_period)
euraud = ta.rsi(request.security("EURAUD", timeframe, close),lookback_period)
eurcad = ta.rsi(request.security("EURCAD", timeframe, close),lookback_period)
eurchf = ta.rsi(request.security("EURCHF", timeframe, close),lookback_period)
eurgbp = ta.rsi(request.security("EURGBP", timeframe, close),lookback_period)
eurjpy = ta.rsi(request.security("EURJPY", timeframe, close),lookback_period)
eurnzd = ta.rsi(request.security("EURNZD", timeframe, close),lookback_period)
eurusd = ta.rsi(request.security("EURUSD", timeframe, close),lookback_period)
gbpaud = ta.rsi(request.security("GBPAUD", timeframe, close),lookback_period)
gbpcad = ta.rsi(request.security("GBPCAD", timeframe, close),lookback_period)
gbpchf = ta.rsi(request.security("GBPCHF", timeframe, close),lookback_period)
gbpjpy = ta.rsi(request.security("GBPJPY", timeframe, close),lookback_period)
gbpnzd = ta.rsi(request.security("GBPNZD", timeframe, close),lookback_period)
gbpusd = ta.rsi(request.security("GBPUSD", timeframe, close),lookback_period)
nzdcad = ta.rsi(request.security("NZDCAD", timeframe, close),lookback_period)
nzdchf = ta.rsi(request.security("NZDCHF", timeframe, close),lookback_period)
nzdjpy = ta.rsi(request.security("NZDJPY", timeframe, close),lookback_period)
nzdusd = ta.rsi(request.security("NZDUSD", timeframe, close),lookback_period)
usdcad = ta.rsi(request.security("USDCAD", timeframe, close),lookback_period)
usdchf = ta.rsi(request.security("USDCHF", timeframe, close),lookback_period)
usdjpy = ta.rsi(request.security("USDJPY", timeframe, close),lookback_period)

aud = math.avg(audcad,audchf,(100-euraud),(100-gbpaud),audjpy,audnzd,audusd)
cad = math.avg((100-audcad),cadchf,(100-eurcad),(100-gbpcad),cadjpy,(100-nzdcad),(100-usdcad))
chf = math.avg((100-audchf),(100-cadchf),(100-eurchf),(100-gbpchf),chfjpy,(100-nzdchf),(100-usdchf))
eur = math.avg(euraud,eurcad,eurchf,eurgbp,eurjpy,eurnzd,eurusd)
gbp = math.avg(gbpaud,gbpcad,gbpchf,(100-eurgbp),gbpjpy,gbpnzd,gbpusd)
jpy = math.avg((100-audjpy),(100-cadjpy),(100-chfjpy),(100-eurjpy),(100-gbpjpy),(100-nzdjpy),(100-usdjpy))
nzd = math.avg((100-audnzd),nzdcad,nzdchf,(100-eurnzd),(100-gbpnzd),nzdjpy,nzdusd)
usd = math.avg((100-audusd),usdcad,usdchf,(100-eurusd),(100-gbpusd),usdjpy,(100-nzdusd))

var strength_table = table.new(position.top_right,2, 9, border_width = 1,border_color= color.gray) 

black = color.new(color.black,0)
white = color.new(color.white,0)
red = color.new(color.red,50)
green = color.new(color.green,50)

str_col(value) =>
    //strcol = value > upper ? color.new(color.green,50) : value < upper and value > lower ? color.new(color.orange,50) : color.new(color.red,50)
    col = color.from_gradient(value, 25, 75, red, green)
    
table.cell(strength_table, 0, 0, "Currency", text_size = size.small, text_color = black, bgcolor = white)
table.cell(strength_table, 1, 0, "Strength", text_size = size.small, text_color = black, bgcolor = white)

table.cell(strength_table, 0, 1, "   AUD   ", text_size = size.small, text_color = black,bgcolor=white)
table.cell(strength_table, 1, 1, str.tostring(aud,format.percent), text_size = size.small, text_color = black, bgcolor = str_col(aud))

table.cell(strength_table, 0, 2, "   CAD   ", text_size = size.small, text_color = black,bgcolor=white)
table.cell(strength_table, 1, 2, str.tostring(cad,format.percent), text_size = size.small, text_color = black, bgcolor = str_col(cad))

table.cell(strength_table, 0, 3, "   CHF   ", text_size = size.small, text_color = black,bgcolor=white)
table.cell(strength_table, 1, 3, str.tostring(chf,format.percent), text_size = size.small, text_color = black, bgcolor = str_col(chf))

table.cell(strength_table, 0, 4, "   EUR   ", text_size = size.small, text_color = black,bgcolor=white)
table.cell(strength_table, 1, 4, str.tostring(eur,format.percent), text_size = size.small, text_color = black, bgcolor = str_col(eur))

table.cell(strength_table, 0, 5, "   GBP   ", text_size = size.small, text_color = black,bgcolor=white)
table.cell(strength_table, 1, 5, str.tostring(gbp,format.percent), text_size = size.small, text_color = black, bgcolor = str_col(gbp))

table.cell(strength_table, 0, 6, "   JPY   ", text_size = size.small, text_color = black,bgcolor=white)
table.cell(strength_table, 1, 6, str.tostring(jpy,format.percent), text_size = size.small, text_color = black, bgcolor = str_col(jpy))

table.cell(strength_table, 0, 7, "   NZD   ", text_size = size.small, text_color = black,bgcolor=white)
table.cell(strength_table, 1, 7, str.tostring(nzd,format.percent), text_size = size.small, text_color = black, bgcolor = str_col(nzd))

table.cell(strength_table, 0, 8, "   USD   ", text_size = size.small, text_color = black,bgcolor=white)
table.cell(strength_table, 1, 8, str.tostring(usd,format.percent), text_size = size.small, text_color = black, bgcolor = str_col(usd))



Reason: