Code: Select all
//@version=5
indicator("AUDNZD Asian Range & Liquidity Sweeps", overlay=true, max_lines_count=500, max_boxes_count=500)
// --- Inputs ---
grp_time = "Session Settings (UTC)"
sessionTime = input.session("2200-0600", title="Asian Session Time", group=grp_time)
// --- Session Logic ---
inSession = time(timeframe.period, sessionTime, "UTC")
sessionStart = inSession and not inSession[1]
sessionEnd = not inSession and inSession[1]
var float asianHigh = na
var float asianLow = na
var box sessionBox = na
var line highLine = na
var line lowLine = na
// --- Draw Asian Session Box ---
if sessionStart
asianHigh := high
asianLow := low
sessionBox := box.new(left=bar_index, top=asianHigh, right=bar_index, bottom=asianLow,
border_color=color.new(color.blue, 70), border_width=1,
bgcolor=color.new(color.blue, 90))
if inSession
asianHigh := math.max(asianHigh, high)
asianLow := math.min(asianLow, low)
box.set_top(sessionBox, asianHigh)
box.set_bottom(sessionBox, asianLow)
box.set_right(sessionBox, bar_index)
// --- Project Liquidity Sweep Lines ---
if sessionEnd
highLine := line.new(x1=bar_index, y1=asianHigh, x2=bar_index + 1, y2=asianHigh,
color=color.red, width=2, style=line.style_dashed)
lowLine := line.new(x1=bar_index, y1=asianLow, x2=bar_index + 1, y2=asianLow,
color=color.green, width=2, style=line.style_dashed)
// Extend lines through London/NY until the next Asian session starts
if not inSession and not na(highLine)
line.set_x2(highLine, bar_index)
line.set_x2(lowLine, bar_index)
// --- Dashboard: Range-to-Cost Analysis ---
// Calculate 14-Day Average Daily Range (ADR)
adr = request.security(syminfo.tickerid, "D", ta.sma(high - low, 14))
// Pip conversion (handles standard forex decimals)
pipMult = syminfo.mintick == 0.00001 ? 10000 : (syminfo.mintick == 0.001 ? 100 : 10000)
adrPips = adr * pipMult
currentRangePips = (asianHigh - asianLow) * pipMult
var table dash = table.new(position.top_right, 2, 2, border_width=1,
border_color=color.new(color.gray, 80), bgcolor=color.new(color.black, 80))
if barstate.islast
table.cell(dash, 0, 0, "14-Day ADR:", text_color=color.white, text_size=size.small)
table.cell(dash, 1, 0, str.tostring(adrPips, "#.0") + " pips", text_color=color.yellow, text_size=size.small)
table.cell(dash, 0, 1, "Asian Range:", text_color=color.white, text_size=size.small)
table.cell(dash, 1, 1, str.tostring(currentRangePips, "#.0") + " pips", text_color=color.aqua, text_size=size.small)