I have this table which shows me the values of RSI, ADX, DMI+ and DMI-. However, after the comma I have 10 number, but I want only 2 after it. How can I make this happen?
//===== RSI =====//
var string GP2 = "RSI Settings"
lenRSI = input.int(14, inline = "11", minval=1, title="RSI Length", group = GP2)
src = input(close, "RSI Source", inline = "11", group = GP2)
upRSI = ta.rma(math.max(ta.change(src), 0), lenRSI)
downRSI = ta.rma(-math.min(ta.change(src), 0), lenRSI)
rsi = downRSI == 0 ? 100 : upRSI == 0 ? 0 : 100 - (100 / (1 + upRSI / downRSI))
//===== DMI+/- =====//
var string GP3 = "ADX and DMI +/- Settings"
lensig = input.int(14, inline = "11", title="ADX Smoothing", minval=1, maxval=50, group = GP3)
voltrig = input.int(20, inline = "11", minval=1, title="ADX Volatility Trigger", group = GP3)
lenDMI = input.int(14, inline = "11", minval=1, title="DMI +/- Length", group = GP3)
upDMI = ta.change(high)
downDMI = -ta.change(low)
plusDMI = na(upDMI) ? na : (upDMI > downDMI and upDMI > 0 ? upDMI : 0)
minusDMI = na(downDMI) ? na : (downDMI > upDMI and downDMI > 0 ? downDMI : 0)
trur = ta.rma(ta.tr, lenDMI)
plus = fixnan(100 * ta.rma(plusDMI, lenDMI) / trur)
minus = fixnan(100 * ta.rma(minusDMI, lenDMI) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
//===== Table =====//
var string GP4 = "Table Position"
string tableYposInput = input.string("top", "Panel position", inline = "11", options = ["top", "middle", "bottom"], group = GP4)
string tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"], group = GP4)
var testTable = table.new(position = position.top_right, columns = 4, rows = 3, bgcolor = color.rgb(250, 250, 250, 100), frame_color = color.rgb(250, 250, 250, 90), frame_width = 2, border_color = color.rgb(250, 250, 250, 90), border_width = 2)
if barstate.islast
table.cell(table_id = testTable, column = 0, row = 0, text = "RSI", text_color = color.rgb(255, 186, 8))
table.cell(table_id = testTable, column = 1, row = 0, text = "ADX", text_color = color.rgb(255, 186, 8))
table.cell(table_id = testTable, column = 2, row = 0, text = "DMI+", text_color = color.rgb(255, 186, 8))
table.cell(table_id = testTable, column = 3, row = 0, text = "DMI-", text_color = color.rgb(255, 186, 8))
table.cell(table_id = testTable, column = 0, row = 1, text = "" + str.tostring(rsi), text_color = color.rgb(255, 186, 8))
table.cell(table_id = testTable, column = 1, row = 1, text = "" + str.tostring(adx), text_color = color.rgb(255, 186, 8))
table.cell(table_id = testTable, column = 2, row = 1, text = "" + str.tostring(plus), text_color = color.rgb(255, 186, 8))
table.cell(table_id = testTable, column = 3, row = 1, text = "" + str.tostring(minus), text_color = color.rgb(255, 186, 8))
You can use the format argument of the str.tostring(value, format)
function.
str.tostring(rsi, ".##")
Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.
En caso de infracción, por favor [email protected] Eliminar
Déjame decir algunas palabras