Session High/Low Lines (Anchored)

indicator("Session High/Low Lines (Anchored)", overlay=true)
// Timezone
nyTZ = "America/New_York"
// Session time ranges (in NY time)
asianStart = timestamp(nyTZ, year, month, dayofmonth, 19, 0)
asianEnd = timestamp(nyTZ, year, month, dayofmonth, 3, 0) + 86400000
londonStart = timestamp(nyTZ, year, month, dayofmonth, 3, 0)
londonEnd = timestamp(nyTZ, year, month, dayofmonth, 11, 0)
nyStart = timestamp(nyTZ, year, month, dayofmonth, 8, 30)
nyEnd = timestamp(nyTZ, year, month, dayofmonth, 17, 0)
midNY = timestamp(nyTZ, year, month, dayofmonth, 12, 30)
// Session conditions
inAsian = time >= asianStart and time < asianEnd
inLondon = time >= londonStart and time < londonEnd
inNY = time >= nyStart and time < nyEnd
newAsian = not inAsian[1] and inAsian
endAsian = inAsian[1] and not inAsian
newLondon = not inLondon[1] and inLondon
endLondon = inLondon[1] and not inLondon
newNY = not inNY[1] and inNY
endNY = inNY[1] and not inNY
// Asian session tracking
var float asianHigh = na
var float asianLow = na
var int asianHighTime = na
var int asianLowTime = na
if newAsian
asianHigh := high
asianLow := low
asianHighTime := time
asianLowTime := time
else if inAsian
if high > asianHigh
asianHigh := high
asianHighTime := time
if low < asianLow
asianLow := low
asianLowTime := time
// London session tracking
var float londonHigh = na
var float londonLow = na
var int londonHighTime = na
var int londonLowTime = na
if newLondon
londonHigh := high
londonLow := low
londonHighTime := time
londonLowTime := time
else if inLondon
if high > londonHigh
londonHigh := high
londonHighTime := time
if low < londonLow
londonLow := low
londonLowTime := time
// NY session tracking
var float nyHigh = na
var float nyLow = na
var int nyHighTime = na
var int nyLowTime = na
if newNY
nyHigh := high
nyLow := low
nyHighTime := time
nyLowTime := time
else if inNY
if high > nyHigh
nyHigh := high
nyHighTime := time
if low < nyLow
nyLow := low
nyLowTime := time
// Draw lines and labels using absolute time
drawLine(fromTime, price, color, labelTxt, isHigh) =>
if not na(fromTime)
line.new(x1=fromTime, y1=price, x2=midNY, y2=price, xloc=xloc.bar_time, color=color, width=1)
offset = price * 0.002
yPos = isHigh ? price + offset : price - offset
label.new(x=fromTime, y=yPos, text=labelTxt, style=label.style_label_left,
xloc=xloc.bar_time, color=color, textcolor=color.white,
size=size.small, yloc=yloc.price)
// Draw lines at end of each session
if endAsian
drawLine(asianHighTime, asianHigh, color.blue, "Asian High", true)
drawLine(asianLowTime, asianLow, color.blue, "Asian Low", false)
if endLondon
drawLine(londonHighTime, londonHigh, color.green, "London High", true)
drawLine(londonLowTime, londonLow, color.green, "London Low", false)
if endNY
drawLine(nyHighTime, nyHigh, color.red, "NY High", true)
drawLine(nyLowTime, nyLow, color.red, "NY Low", false)
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.
Declinazione di responsabilità
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.