I'm looking for the best way to add text to a table cell when a certain condition is met. These are the conditions:
- When current close is above or below vwap by 10%
- The cell changes color to Green and the text 'Up' appears with no vwap data
- The cell changes color to Red and the text 'Down' appears with no vwap data
- When neither of these conditions are meet, no color change and the word 'Neutral' appears.
indicator("VWAP", "", true)
averagedata = input.source(close, title="Vwap setting")
vwapdata = ta.vwap(averagedata)
pcchange = input.int(defval=10, title="Percentage Change", minval=1, maxval=200)
var changedup = close > vwapdata * 0.01
var changeddown = close < vwapdata * 0.01
buybox = color.green
selbox = color.red
nbox = color.navy
var table vwapdataaa = table.new(position.top_right, 3, 3, bgcolor = color.gray, frame_width = 2, frame_color = color.black)
if barstate.islast
table.cell(vwapdataaa, 0, 0, str.tostring(vwapdata, format.mintick), text_color = color.white)
table.cell(vwapdataaa, 0, 2, str.tostring(vwapdata, format.mintick), bgcolor= (close > vwapdata) ? buybox : (close < vwapdata) ? selbox : nbox, text_color=color.white)````
I have managed to get the colors to change when the conditions are met, but can't work out, the rest