Footprint imbalance and cell colouring
A footprint imbalance read: count the diagonal imbalances on each bar, mark the stacked runs that matter, recolour the candle when one side owned the bar, and show the balance of the two sides in the panel.
//@xfscript 1
indicator("Footprint Imbalance")
let ratio: float = input.float(3, "ratio", "Imbalance ratio", 1.5, 10, 0.5)
let stack: int = input.int(3, "stack", "Stacked rows", 2, 10, 1)
let buy_color: color = input.color("#22C55E", "buyColor", "Buying")
let sell_color: color = input.color("#EF4444", "sellColor", "Selling")
let has_ladder: bool = cell.available()
let buy_rows: float = cell.ask_imbalances(ratio)
let sell_rows: float = cell.bid_imbalances(ratio)
let stacked_buy: bool = has_ladder && cell.stacked_ask(ratio, stack)
let stacked_sell: bool = has_ladder && cell.stacked_bid(ratio, stack)
let lean: float = buy_rows - sell_rows
plot.marker(stacked_buy, low, buy_color, "triangle", "below", 10, 3)
plot.marker(stacked_sell, high, sell_color, "triangle", "above", 10, 3)
plot.candle_color(stacked_buy, buy_color, 0.75)
plot.candle_color(stacked_sell, sell_color, 0.75)
plot.dot(has_ladder, cell.poc_price(), "#F59E0B", 3)
plot.histogram(nz(lean, 0), buy_color, sell_color)
plot.panel_hline(0, "#6B7280", "dotted", "Balanced")