Depth walls
Depth of book: the biggest resting bid and the biggest resting offer in the book held as labelled levels, a marker when a new wall at least twice the previous one appears, and the wall sizes in the readout. Without depth it says so and draws nothing false.
//@xfscript 1
indicator("Depth Walls")
let jump: float = input.float(2, "jump", "New wall multiple", 1.1, 10, 0.1)
let bid_color: color = input.color("#22C55E", "bidColor", "Bid wall")
let ask_color: color = input.color("#EF4444", "askColor", "Ask wall")
let has_depth: bool = l2.supported() && l2.available()
var bid_wall: float = nan
var bid_wall_size: float = nan
var ask_wall: float = nan
var ask_wall_size: float = nan
bid_wall := nz(bid_wall[1], nan)
bid_wall_size := nz(bid_wall_size[1], nan)
ask_wall := nz(ask_wall[1], nan)
ask_wall_size := nz(ask_wall_size[1], nan)
let new_bid_wall: bool = has_depth && l2.max_bid_size() >= nz(bid_wall_size, 0) * jump && !is_nan(bid_wall_size)
let new_ask_wall: bool = has_depth && l2.max_ask_size() >= nz(ask_wall_size, 0) * jump && !is_nan(ask_wall_size)
plot.marker(new_bid_wall, l2.max_bid_price(), bid_color, "square", "below", 9, 2)
plot.marker(new_ask_wall, l2.max_ask_price(), ask_color, "square", "above", 9, 2)
if has_depth {
bid_wall := l2.max_bid_price()
bid_wall_size := l2.max_bid_size()
ask_wall := l2.max_ask_price()
ask_wall_size := l2.max_ask_size()
}
plot.hline(bid_wall, bid_color, 2, "solid", "Bid wall")
plot.hline(ask_wall, ask_color, 2, "solid", "Ask wall")
if l2.supported() {
plot.label(str.concat("BID WALL ", format.compact(bid_wall_size), " ASK WALL ", format.compact(ask_wall_size)), "#E5E7EB")
} else {
plot.label("DEPTH OFF ON THIS CHART", "#6B7280")
}