I have updated this script to show spread in % instead of prices of BID/ASK. I have also fixed a issue that sometime the bar doesn't have BID or ASK (thus causing error a label on chart), if that's the case, it will pull data from 1 bar ago.
def lastPrice = if isnan(close(priceType = "LAST")) then lastPrice[1] else close(priceType = "LAST");
def askPrice = if isnan(close(priceType = "ASK")) then askPrice[1] else close(priceType = "ASK");
def bidPrice = if isnan(close(priceType = "BID")) then bidPrice[1] else close(priceType = "BID");
def spreadPercent = ((askPrice-bidPrice)/lastPrice);
AddLabel(yes, AsPercent(spreadPercent), if spreadPercent <= .02 then Color.CYAN else COLOR.RED);
Last edited: