Building on the Big Trades markers
The markers the Big Trades indicator already draws: keep only the largest one on each bar, ring the ones above your size, keep a running balance of big buying against big selling in the panel, and colour the candle that carried the biggest print of the session.
//@xfscript 1
indicator("Big Trades Balance")
let ring_size: float = input.float(250, "ringSize", "Ring above", 1, 100000, 1)
let buy_color: color = input.color("#22C55E", "buyColor", "Buying")
let sell_color: color = input.color("#EF4444", "sellColor", "Selling")
let shown: bool = bigtrades.available()
let marks: float = bigtrades.count()
let size0: float = nz(bigtrades.size(0), 0)
let size1: float = nz(bigtrades.size(1), 0)
let pick_second: bool = size1 > size0
var top_size: float = 0
var top_price: float = nan
var top_side: side = "UNDEFINED"
top_size := size0
top_price := bigtrades.price(0)
top_side := bigtrades.side(0)
if pick_second {
top_size := size1
top_price := bigtrades.price(1)
top_side := bigtrades.side(1)
}
let ringed: bool = shown && marks > 0 && top_size >= ring_size
plot.marker(ringed && top_side == "BUY", top_price, buy_color, "circle", "below", 16, 0)
plot.marker(ringed && top_side == "SELL", top_price, sell_color, "circle", "above", 16, 0)
var balance: float = 0
balance := nz(balance[1], 0)
if shown && marks > 0 && top_side == "BUY" {
balance := balance + top_size
}
if shown && marks > 0 && top_side == "SELL" {
balance := balance - top_size
}
plot.panel_area(balance, "#6B7280", 0.15)
plot.panel_line(balance, "#E5E7EB", 2, "solid")
plot.panel_hline(0, "#6B7280", "dotted", "Even")
if shown {
plot.label(str.concat("BIG TRADE BALANCE ", format.compact(balance)), "#E5E7EB")
} else {
plot.label("ADD BIG TRADES TO THIS CHART", "#6B7280")
}