简体   繁体   English

表格单元格的背景颜色根据 2 个条件而变化

[英]Background color of table cell changes depending on 2 conditions

i would like to change the background color of a cell.我想更改单元格的背景颜色。 The change will depend on 2 conditions, if the final value of cell is >20 then green, if less than -20 then red.更改将取决于 2 个条件,如果单元格的最终值 >20 则为绿色,如果小于 -20 则为红色。

    table.cell(panel, 5, 0, str.tostring(finalvalue), bgcolor=close>20?color.green:color.red)'

I managed the first condition but how can I add the second condition pls我管理了第一个条件,但如何添加第二个条件

Thanks in advance提前致谢

bgcolor=close>20?color.green:color.red)

Will change the backround to green if the close price is above 20 and to red otherwise.如果收盘价高于 20,背景将变为绿色,否则变为红色。

What you need is a second ternary operator in this condition.在这种情况下,您需要的是第二个三元运算符。

bgcolor = finalvalue > 20 ? color.green : finalvalue < -20 color.red : color.yellow)

In this statement, the background will be green if finalvalue is greater than 20, and it will be red if it is less than -20 and it will be yellow if it is in between.在此语句中,如果finalvalue大于 20,则背景为绿色,如果小于 -20,则为红色,如果介于两者之间,则为黄色

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM