我正在使用我自己的指标制作类似于 Tradingview 中 thinkorswim 标签的东西。我对编程完全陌生。
我正在构建来自社区的开源代码,但我被困在了根据不同阈值对不同指标值进行颜色编码的任务中。(目前,它们根据之前的值着色为绿色和红色,并且所有指标/列/都相同)。
例如,我希望使 SQN 值(编码为 RSI0)例如仅在值为 0.7 之后为浅绿色,而 Β 值仅在 1.1 之后为浅绿色。
**有人可以帮忙吗?**
// set indicator values
// symbol 0
f_add_indi(indi0, 0 * 40 + 0, RSI0, RSI0[1])
f_add_indi(indi1, 0 * 40 + 3, round(macdLine0,2), round(macdLine0[1],2))
f_add_indi(indi1, 0 * 40 + 6, round(signalLine0,2), round(signalLine0[1],2))
f_add_indi(indi1, 0 * 40 + 9, round(histLine0,2), round(histLine0[1],2))
f_add_indi(indi2, 0 * 40 + 12, diplus0, diplus0[1])
f_add_indi(indi2, 0 * 40 + 15, diminus0, diminus0[1])
f_add_indi(indi2, 0 * 40 + 18, adx0, adx0[1])
f_add_indi(indi3, 0 * 40 + 21, adxc0, adxc0[1])
f_add_indi(indi4, 0 * 40 + 24, beta0, beta0[1])
f_add_indi(indi5, 0 * 40 + 27, udv0, udv0[1])
f_add_indi(indi6, 0 * 40 + 30, ma01, ma01[1])
f_add_indi(indi7, 0 * 40 + 33, ma02, ma02[1])
f_add_indi(indi8, 0 * 40 + 36, ind8, ind8[1])
f_add_indi(indi8, 0 * 40 + 39, ind9, ind9[1])
f_add_indi(indi8, 0 * 40 + 42, ind10, ind10[1])
var indicatorTable = table.new(position = f_getPosition(_pos) , columns = 23, rows= 4, frame_color = color.black, frame_width = 4, border_width = 1, border_color = color.black)
if barstate.islast
// symbols
table.cell(table_id = indicatorTable, column = 0, row = 0, text = "Indicator", bgcolor = color.gray, text_color = color.white)
table.cell(table_id = indicatorTable, column = 0, row = 1, text = "Panel", bgcolor = color.gray, text_color = color.white)
table.cell(table_id = indicatorTable, column = 0, row = 2, text = symbol0, text_halign = text.align_left, bgcolor = color.black, text_color = color.white)
// indicator values
col = color.yellow
for j = 0 to 4
for i = 0 to 15
index = j * 40 + i * 3
if array.get(indicators, index) == 1 // enabled
table.cell(table_id = indicatorTable, column = i + 1, row = 1, text = array.get(indinames, i), bgcolor = col, text_color = color.black)
if i >= 1 and i <= 6
if i == 1
table.cell(table_id = indicatorTable, column = i + 1, row = 0, text = "", bgcolor = col, text_color = color.black)
table.cell(table_id = indicatorTable, column = i + 2, row = 0, text = "M A C D", bgcolor = col, text_color = color.black)
table.cell(table_id = indicatorTable, column = i + 3, row = 0, text = "", bgcolor = col, text_color = color.black)
if i == 4
table.cell(table_id = indicatorTable, column = i + 1, row = 0, text = "", bgcolor = col, text_color = color.black)
table.cell(table_id = indicatorTable, column = i + 2, row = 0, text = "D M I", bgcolor = col, text_color = color.black)
table.cell(table_id = indicatorTable, column = i + 3, row = 0, text = "", bgcolor = col, text_color = color.black)
if i == 3 or i == 6
col := col == color.yellow ? color.orange : color.yellow
else
table.cell(table_id = indicatorTable, column = i + 1, row = 0, text = "", bgcolor = col, text_color = color.black)
col := col == color.yellow ? color.orange : color.yellow
bgcol = array.get(indicators, index + 1) > array.get(indicators, index + 2) ? color.lime :
array.get(indicators, index + 1) < array.get(indicators, index + 2) ? color.red :
color.gray
txtcol = array.get(indicators, index + 1) > array.get(indicators, index + 2) ? color.black :
array.get(indicators, index+ 1) < array.get(indicators, index + 2) ? color.white :
color.black
txt = tostring(array.get(indicators, index + 1), array.get(precision, i))
table.cell(table_id = indicatorTable, column = i + 1, row = j + 2, text = txt, bgcolor = bgcol, text_color = txtcol)// }