plot "Diff, %" = round(100 * ((bid + ask) / 2 - close) / close, 2);
AssignBackgroundColor(if "Diff, %" > 0 then Color.UPTICK else if "Diff, %" < 0 then Color.DOWNTICK else Color.GRAY);
This example script is used as a custom quote. It calculates percentage difference between mark and last prices and assigns colors according to its sign.
Note that you cannot reference historical data using this function, e.g.
bid is an invalid expression.