INVITE-ONLY SCRIPT

session High/Low (Triumm)

26
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © Triummm




//version=6
indicator("Trading session High/Low (Triumm)", overlay=true)

//──────── Fixed timezone (NY clock = UTC‑4) ────────
sessTz = "Etc/GMT+4"

//──────── Toggle for swept-dot feature ─────────────
useSweepDots = input.bool(true, "Dot swept lines", tooltip="If ON, a level turns dotted once price sweeps it AFTER the session closes")

//──────── Session inputs ────────────────────────────────────────────────────
// Asia
showAsia = input.bool(true, "Show Asia", group="Asia Session")
asiaRange = input.session("1800-0300", "Asia Time (UTC‑4) 24h", group="Asia Session")
asiaCol = input.color(color.rgb(243, 33, 33), "Color", group="Asia Session")
asiaW = input.int(1, "Width", minval=1, maxval=5, group="Asia Session")
asiaStyleStr = input.string("Solid", "Line Style", options=["Solid","Dashed","Dotted"], group="Asia Session")
asiaTransp = input.int(0, "Transparency (%)", minval=0, maxval=100, group="Asia Session")
// London
showLon = input.bool(true, "Show London", group="London Session")
lonRange = input.session("0300-0930", "London Time (UTC‑4) 24h", group="London Session")
lonCol = input.color(color.rgb(76, 153, 255), "Color", group="London Session")
lonW = input.int(1, "Width", minval=1, maxval=5, group="London Session")
lonStyleStr = input.string("Solid", "Line Style", options=["Solid","Dashed","Dotted"], group="London Session")
lonTransp = input.int(0, "Transparency (%)", minval=0, maxval=100, group="London Session")
// New York
showNY = input.bool(true, "Show NY", group="NY Session")
nyRange = input.session("0930-1600", "NY Time (UTC‑4) 24h", group="NY Session")
nyCol = input.color(color.rgb(11, 173, 125), "Color", group="NY Session")
nyW = input.int(1, "Width", minval=1, maxval=5, group="NY Session")
nyStyleStr = input.string("Solid", "Line Style", options=["Solid","Dashed","Dotted"], group="NY Session")
nyTransp = input.int(0, "Transparency (%)", minval=0, maxval=100, group="NY Session")

//──────── Helpers ───────────────────────────────────────────────────────────
styleFromStr(s) =>
s == "Dashed" ? line.style_dashed : s == "Dotted" ? line.style_dotted :line.style_solid

resetStyleIfNeeded(l, baseStyle) =>
if not na(l)
line.set_style(l, baseStyle)

// map styles
asiaStyle = styleFromStr(asiaStyleStr)
lonStyle = styleFromStr(lonStyleStr)
nyStyle = styleFromStr(nyStyleStr)

//──────── Asia state ────────────────────────────────────────────────────────
var float asia_hi = na
var float asia_lo = na
var int asia_hi_bi = na
var int asia_lo_bi = na
var line asia_hL = na
var line asia_lL = na
var bool asia_hi_sw = false
var bool asia_lo_sw = false

inAsia = not na(time(timeframe.period, asiaRange, sessTz))
newAsia = inAsia and not inAsia[1]

if newAsia
line.delete(asia_hL), line.delete(asia_lL)
asia_hi := high, asia_lo := low
asia_hi_bi := na, asia_lo_bi := na
asia_hi_sw := false, asia_lo_sw := false

if showAsia and inAsia
if (na(asia_hi_bi) and bar_index > bar_index[1]) or high > asia_hi
asia_hi := high, asia_hi_bi := bar_index, asia_hi_sw := false
if na(asia_hL)
asia_hL := line.new(asia_hi_bi, asia_hi, asia_hi_bi + 1, asia_hi, xloc.bar_index, extend.right,color.new(asiaCol, asiaTransp), asiaStyle, asiaW)
else
line.set_xy1(asia_hL, asia_hi_bi, asia_hi)
line.set_xy2(asia_hL, asia_hi_bi + 1, asia_hi)
line.set_style(asia_hL, asiaStyle)
if (na(asia_lo_bi) and bar_index > bar_index[1]) or low < asia_lo
asia_lo := low, asia_lo_bi := bar_index, asia_lo_sw := false
if na(asia_lL)
asia_lL := line.new(asia_lo_bi, asia_lo, asia_lo_bi + 1, asia_lo, xloc.bar_index, extend.right,color.new(asiaCol, asiaTransp), asiaStyle, asiaW)
else
line.set_xy1(asia_lL, asia_lo_bi, asia_lo)
line.set_xy2(asia_lL, asia_lo_bi + 1, asia_lo)
line.set_style(asia_lL, asiaStyle)

// sweep detection AFTER session
canSweepAsia = useSweepDots and not inAsia
if showAsia
if canSweepAsia
if not asia_hi_sw and not na(asia_hi_bi) and high > asia_hi // strict break
line.set_style(asia_hL, line.style_dotted), asia_hi_sw := true
if not asia_lo_sw and not na(asia_lo_bi) and low < asia_lo // strict break
line.set_style(asia_lL, line.style_dotted), asia_lo_sw := true
else
resetStyleIfNeeded(asia_hL, asiaStyle)
resetStyleIfNeeded(asia_lL, asiaStyle)

if not showAsia
line.delete(asia_hL), line.delete(asia_lL)
asia_hL := na, asia_lL := na

//──────── London state ─────────────────────────────────────────────────────
var float lon_hi = na
var float lon_lo = na
var int lon_hi_bi = na
var int lon_lo_bi = na
var line lon_hL = na
var line lon_lL = na
var bool lon_hi_sw = false
var bool lon_lo_sw = false

inLon = not na(time(timeframe.period, lonRange, sessTz))
newLon = inLon and not inLon[1]

if newLon
line.delete(lon_hL), line.delete(lon_lL)
lon_hi := high, lon_lo := low
lon_hi_bi := na, lon_lo_bi := na
lon_hi_sw := false, lon_lo_sw := false

if showLon and inLon
if (na(lon_hi_bi) and bar_index > bar_index[1]) or high > lon_hi
lon_hi := high, lon_hi_bi := bar_index, lon_hi_sw := false
if na(lon_hL)
lon_hL := line.new(lon_hi_bi, lon_hi, lon_hi_bi + 1, lon_hi,
xloc.bar_index, extend.right,
color.new(lonCol, lonTransp), lonStyle, lonW)
else
line.set_xy1(lon_hL, lon_hi_bi, lon_hi)
line.set_xy2(lon_hL, lon_hi_bi + 1, lon_hi)
line.set_style(lon_hL, lonStyle)
if (na(lon_lo_bi) and bar_index > bar_index[1]) or low < lon_lo
lon_lo := low, lon_lo_bi := bar_index, lon_lo_sw := false
if na(lon_lL)
lon_lL := line.new(lon_lo_bi, lon_lo, lon_lo_bi + 1, lon_lo,
xloc.bar_index, extend.right,
color.new(lonCol, lonTransp), lonStyle, lonW)
else
line.set_xy1(lon_lL, lon_lo_bi, lon_lo)
line.set_xy2(lon_lL, lon_lo_bi + 1, lon_lo)
line.set_style(lon_lL, lonStyle)

// sweep detection AFTER session
canSweepLon = useSweepDots and not inLon
if showLon
if canSweepLon
if not lon_hi_sw and not na(lon_hi_bi) and high > lon_hi
line.set_style(lon_hL, line.style_dotted), lon_hi_sw := true
if not lon_lo_sw and not na(lon_lo_bi) and low < lon_lo
line.set_style(lon_lL, line.style_dotted), lon_lo_sw := true
else
resetStyleIfNeeded(lon_hL, lonStyle)
resetStyleIfNeeded(lon_lL, lonStyle)

if not showLon
line.delete(lon_hL), line.delete(lon_lL)
lon_hL := na, lon_lL := na

//──────── New York state ───────────────────────────────────────────────────
var float ny_hi = na
var float ny_lo = na
var int ny_hi_bi = na
var int ny_lo_bi = na
var line ny_hL = na
var line ny_lL = na
var bool ny_hi_sw = false
var bool ny_lo_sw = false

inNY = not na(time(timeframe.period, nyRange, sessTz))
newNY = inNY and not inNY[1]

if newNY
line.delete(ny_hL), line.delete(ny_lL)
ny_hi := high, ny_lo := low
ny_hi_bi := na, ny_lo_bi := na
ny_hi_sw := false, ny_lo_sw := false

if showNY and inNY
if (na(ny_hi_bi) and bar_index > bar_index[1]) or high > ny_hi
ny_hi := high, ny_hi_bi := bar_index, ny_hi_sw := false
if na(ny_hL)
ny_hL := line.new(ny_hi_bi, ny_hi, ny_hi_bi + 1, ny_hi,
xloc.bar_index, extend.right,
color.new(nyCol, nyTransp), nyStyle, nyW)
else
line.set_xy1(ny_hL, ny_hi_bi, ny_hi)
line.set_xy2(ny_hL, ny_hi_bi + 1, ny_hi)
line.set_style(ny_hL, nyStyle)
if (na(ny_lo_bi) and bar_index > bar_index[1]) or low < ny_lo
ny_lo := low, ny_lo_bi := bar_index, ny_lo_sw := false
if na(ny_lL)
ny_lL := line.new(ny_lo_bi, ny_lo, ny_lo_bi + 1, ny_lo,
xloc.bar_index, extend.right,
color.new(nyCol, nyTransp), nyStyle, nyW)
else
line.set_xy1(ny_lL, ny_lo_bi, ny_lo)
line.set_xy2(ny_lL, ny_lo_bi + 1, ny_lo)
line.set_style(ny_lL, nyStyle)

// sweep detection AFTER session
canSweepNY = useSweepDots and not inNY
if showNY
if canSweepNY
if not ny_hi_sw and not na(ny_hi_bi) and high > ny_hi
line.set_style(ny_hL, line.style_dotted), ny_hi_sw := true
if not ny_lo_sw and not na(ny_lo_bi) and low < ny_lo
line.set_style(ny_lL, line.style_dotted), ny_lo_sw := true
else
resetStyleIfNeeded(ny_hL, nyStyle)
resetStyleIfNeeded(ny_lL, nyStyle)

if not showNY
line.delete(ny_hL), line.delete(ny_lL)
ny_hL := na, ny_lL := na

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.