Chart markings

Chart markings: an outlined box on every three bar gap, a filled zone that ends the moment price fills it, and the last gap edge held as a level.

//@xfscript 1
indicator("Gap Markings")

let bars_right: int = input.int(40, "barsRight", "Bars right", 1, 500, 1)
let outline: bool = input.bool(true, "outline", "Outline instead of fill")
let up_color: color = input.color("#22C55E", "upColor", "Bullish gap")
let down_color: color = input.color("#EF4444", "downColor", "Bearish gap")

let ready: bool = bar_index >= 2
let gap_up: bool = ready && low > high[2]
let gap_down: bool = ready && high < low[2]

plot.box(gap_up && outline, low, high[2], up_color, 1, -1, bars_right, 1, "solid", "Gap")
plot.box(gap_down && outline, low[2], high, down_color, 1, -1, bars_right, 1, "solid", "Gap")
plot.zone(gap_up && !outline, low, high[2], up_color, 0.16, -1, bars_right, "bullish")
plot.zone(gap_down && !outline, low[2], high, down_color, 0.16, -1, bars_right, "bearish")

var last_edge: float = nan
last_edge := nz(last_edge[1], nan)
if gap_up {
  last_edge := high[2]
}
if gap_down {
  last_edge := low[2]
}

plot.hline(last_edge, "#9CA3AF", 1, "dotted", "Last gap edge")
plot.marker(gap_up, low, up_color, "diamond", "below", 8, 3)
plot.marker(gap_down, high, down_color, "diamond", "above", 8, 3)

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