Text overlay on every bar

A text overlay: the numbers that matter printed above or below each candle, placed on the side that keeps price clear, and hidden when the chart is zoomed out.

//@xfscript 1
indicator("Bar Stats")

let font: float = input.float(9, "font", "Font size", 6, 24, 1)
let slot: float = input.float(84, "slot", "Minimum bar width", 10, 200, 2)
let up_color: color = input.color("#22C55E", "upColor", "Positive")
let down_color: color = input.color("#EF4444", "downColor", "Negative")
let flat_color: color = input.color("#9CA3AF", "flatColor", "Neutral")

let total: float = tape.volume()
let delta: float = tape.delta()
let delta_percent: float = delta / total * 100
let has_tape: bool = tape.available() && total > 0

let body: string = str.concat(format.compact(delta), "\n", format.fixed(nz(delta_percent, 0), 1), "%\n", format.compact(total))

let bearish: bool = delta < 0

if bearish {
  plot.text(has_tape, high, body, down_color, "above", font, 4, slot)
} else if delta > 0 {
  plot.text(has_tape, low, body, up_color, "below", font, 4, slot)
} else {
  plot.text(has_tape, low, body, flat_color, "below", font, 4, slot)
}

Every layer of the market, Orderflow to optionflow, on one chart.

Institutional grade Orderflow data with backtesting and journaling built in. Join the waitlist for early access.

Get Access