plot spread = ask - bid; AssignBackgroundColor(if spread < 0.05 then Color.GREEN else if spread < 0.25 then Color.YELLOW else Color.RED);
This example script is used as a custom quote. It calculates a bid-ask spread and assigns different colors according to its value.
Note that you cannot reference historical data using this function, e.g.
ask is an invalid expression.