Session tool

A session tool: the opening price of the cash session, average daily range projections around it, and the session box.

//@xfscript 1
indicator("Session Tool")

let window: string = "0930-1600"
let zone: string = "America/New_York"
let adr_length: int = input.int(5, "adrLength", "ADR sessions", 1, 252, 1)
let open_color: color = input.color("#E5E7EB", "openColor", "Session open")
let target_color: color = input.color("#6B7280", "targetColor", "ADR targets")

let in_session: bool = session.in(window, zone)
let was_in: bool = bar_index > 0 && in_session[1]
let first_bar: bool = in_session && !was_in
let session_end: bool = was_in && !in_session

let anchor: float = session.open(window, zone)
let adr: float = session.adr(adr_length, window, zone)

var box_high: float = nan
var box_low: float = nan
box_high := nz(box_high[1], nan)
box_low := nz(box_low[1], nan)
if first_bar {
  box_high := high
  box_low := low
}
if in_session {
  box_high := math.max(nz(box_high, high), high)
  box_low := math.min(nz(box_low, low), low)
}

if in_session {
  plot.line(anchor, open_color, 2, "solid")
  plot.line(anchor + adr / 2, target_color, 1, "dashed")
  plot.line(anchor - adr / 2, target_color, 1, "dashed")
  plot.zone(box_high, box_low, target_color, 0.08)
}

plot.box(session_end, box_high, box_low, open_color, 1, 0, 0, 1, "solid", "Session")
plot.marker(first_bar, low, open_color, "diamond", "below", 8, 4)
plot.label(str.concat("ADR ", format.fixed(adr, 2)), target_color)

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