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.
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.