OPEN-SOURCE SCRIPT

Session Boxes

193
//version=6
indicator("Session Boxes", overlay=true)

// Sessions Definitionen
tokyo_start = timestamp(year(time), month(time), dayofmonth(time), 0, 0)
tokyo_end = timestamp(year(time), month(time), dayofmonth(time), 9, 0)
london_start = timestamp(year(time), month(time), dayofmonth(time), 7, 0)
london_end = timestamp(year(time), month(time), dayofmonth(time), 16, 0)
newyork_start = timestamp(year(time), month(time), dayofmonth(time), 12, 0)
newyork_end = timestamp(year(time), month(time), dayofmonth(time), 21, 0)

// Farben (dezent)
color_tokyo = color.rgb(204, 204, 204, 50)
color_london = color.rgb(170, 170, 170, 50)
color_newyork = color.rgb(136, 136, 136, 50)

// Funktion zum Zeichnen der Session-Boxen
sessionBox(startTime, endTime, sessionColor) =>
var int startIndex = na
var int endIndex = na
var float sessionHigh = na
var float sessionLow = na

isSession = (time >= startTime and time <= endTime)

if isSession
if na(startIndex)
startIndex := bar_index
sessionHigh := high
sessionLow := low
endIndex := bar_index
sessionHigh := math.max(sessionHigh, high)
sessionLow := math.min(sessionLow, low)

if not na(startIndex) and not na(endIndex)
box.new(left=int(startIndex), right=int(endIndex), top=sessionHigh, bottom=sessionLow, bgcolor=sessionColor, border_color=sessionColor)

// Sessions auf dem Chart zeichnen
sessionBox(tokyo_start, tokyo_end, color_tokyo)
sessionBox(london_start, london_end, color_london)
sessionBox(newyork_start, newyork_end, color_newyork)

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน