Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("ICT Killzones by Mozi", overlay = true)
- // Default color constants using tranparency of 25.
- LONDON_COLOR = #FFFFFF03
- NEWYORK_COLOR = #FFFFFF03
- DAY_END_COLOR = #FFFFFF03
- NEWYORKLUNCH_COLOR = #FF000006
- NO_COLOR = color(na)
- VERTICAL_LINE = #FFFFFF35
- JUDAS_COLOR = color.yellow
- // FUNCTIONS
- in_session(sess) =>
- not na(time(timeframe.period, sess))
- start_time(sess) =>
- int startTime = na
- startTime := in_session(sess) and not in_session(sess)[1] ? time : startTime[1]
- startTime
- is_new_session(res, sess) =>
- t = time(res, sess)
- na(t[1]) and not na(t) or t[1] < t
- BarInSession(sess) =>
- time(timeframe.period, sess) != 0
- _hline(StartTime, EndTime, Price, Color, Style, Width) =>
- return_1 = line.new(StartTime, Price, EndTime, Price, xloc=xloc.bar_time, extend=extend.none, color=Color, style=Style, width=Width)
- // Allow user to change the colors.
- londonKillzone = input.color(LONDON_COLOR, "London Killzone", group="Color Settings")
- newYorkKillzone = input.color(NEWYORK_COLOR, "New York Killzone", group="Color Settings")
- newYorkLunchTime = input.color(NEWYORKLUNCH_COLOR, "New York Lunch", group="Color Settings")
- dayEndColor = input.color(DAY_END_COLOR, "Daily End Color", group="Color Settings")
- // Function returns `true` when the bar's time is
- timeInRange(tf, session) => time(tf, session) != 0
- showKillzones = input(true, title="Show Killzones?", group="Default Settings")
- var chartIs30MinOrLess = timeframe.isseconds or (timeframe.isintraday and timeframe.multiplier <=30)
- sessionColor = if chartIs30MinOrLess and showKillzones
- switch
- timeInRange(timeframe.period, input.session(title='London Killzone', defval='0200-0500', group="Time Settings")) => londonKillzone
- timeInRange(timeframe.period, input.session(title='New York Killzone', defval='0700-1000', group="Time Settings")) => newYorkKillzone
- timeInRange(timeframe.period, input.session(title="New York Lunch", defval="1200-1300", group="Time Settings")) => newYorkLunchTime
- timeInRange(timeframe.period, input.session(title="Daily End Rallye", defval="1500-1600", group="Time Settings")) => dayEndColor
- bgcolor(sessionColor)
- asiashow = input(true, title="Show Asia Range?", group="Default Settings")
- asiacolor = input(color.new(color.white, 90), 'Asia Range Color', group="Color Settings")
- asiabordercolor = color.new(color.white, 100)
- asia = input.session(title='Asia Session', defval='2000-0001', group="Time Settings")
- //ASIA BOX
- asia_session = is_new_session('1440', asia)
- float _asialow = na
- float _asiahigh = na
- _asiabox = box(na)
- _asiastart = start_time(asia)
- _asialow := asia_session ? low : in_session(asia) ? math.min(low, _asialow[1]) : na
- _asiahigh := asia_session ? high : in_session(asia) ? math.max(high, _asiahigh[1]) : na
- if in_session(asia)
- if in_session(asia)[1]
- box.delete(_asiabox[1])
- if low < _asialow
- _asialow := low
- _asialow
- if high > _asiahigh
- _asiahigh := high
- _asiahigh
- if asiashow
- _asiabox := box.new(_asiastart, _asiahigh, time, _asialow, xloc=xloc.bar_time, bgcolor=asiacolor, border_color=asiabordercolor, border_style=line.style_solid)
- _asiabox
- // Judas Swing
- float _midnightopen = na
- //midnight = input.session(title='Midnight Opening Price', defval='0000-0005', group="Time Settings")
- //midnight_session = is_new_session('1440', midnight)
- //_midnight = start_time(midnight)
- //_midnightopen := midnight_session ? open : in_session(midnight) ? open : na
- judasshow = input(true, title="Show Judas Swing?", group="Default Settings", tooltip="It only highlights the time when the Judas Swing usually occurs, not the actual Judas Swing. You need to check on your charts, if there is a Judas Swing or not.")
- judascolor = input(color.new(color.yellow, 95), 'Judas Swing Color', group="Color Settings")
- judasbordercolor = color.new(color.white, 100)
- judas = input.session(title='Judas Swing Time', defval='0000-0500', group="Time Settings")
- judas_session = is_new_session('1440', judas)
- float _judaslow = na
- float _judashigh = na
- _judasbox = box(na)
- _judasstart = start_time(judas)
- _judaslow := judas_session ? low : in_session(judas) ? math.min(low, _judaslow[1]) : na
- _judashigh := judas_session ? high : in_session(judas) ? math.max(high, _judashigh[1]) : na
- if in_session(judas)
- if in_session(judas)[1]
- box.delete(_judasbox[1])
- if low < _judaslow
- _judaslow := low
- _judaslow
- if high > _judashigh
- _judashigh := high
- _judashigh
- if judasshow
- _judasbox := box.new(_judasstart, _judashigh, time, _judaslow, xloc=xloc.bar_time, bgcolor=judascolor, border_color=judasbordercolor, border_style=line.style_solid)
- _judasbox
- // MARK NON-FARM PAYROLL FRIDAYS
- NONPAYROLLFRIDAYCOLOR = #a8325610
- nonPayRollFridayColor = input.color(NONPAYROLLFRIDAYCOLOR, "Non-Farm Payroll Color", group="Color Settings")
- nonPayRollFridayShow = input(true, title="Show Non-Farm Payroll Fridays?", group="Default Settings")
- bgColor = nonPayRollFridayColor
- if dayofweek == dayofweek.friday and dayofmonth < 7 and nonPayRollFridayShow
- bgColor := nonPayRollFridayColor
- else
- bgColor := na
- bgcolor(bgColor)
- plotshape(dayofweek == dayofweek.friday and dayofmonth < 7 and hour == 1 and minute == 30 and nonPayRollFridayShow ? true : false, text="NFP Friday", color=na, offset=0, style=shape.circle, location = location.top, textcolor=color.yellow, size=size.normal, editable=false)
- // HOLIDAYS IN EUROPE AND US
- HOLIDAY_COLOR = #ff000008
- holidayColor = input.color(HOLIDAY_COLOR, "Holiday Color", group="Color Settings")
- holidayShow = input(true, title="Highlight Holidays?", group="Default Settings")
- hYear = array.new_int(0)
- hMonth = array.new_int(0)
- hDay = array.new_int(0)
- hName = array.new_string(0)
- _title= ""
- _year = 0
- _month = 0
- _day = 0
- _date = timestamp("5 Sep 2022 05:00")
- // US HOLIDAYS
- // New Years Day
- _date := input.time(timestamp("1 Jan 2022 05:00"), title="New Year's Day", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "New Year's Day")
- // Martin Luther King Jr. Day
- _date := input.time(timestamp("17 Jan 2022 05:00"), title="Martin Luther King Jr. Day", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Martin Luther King Jr. Day")
- // Washington's Birthday
- _date := input.time(timestamp("21 Feb 2022 05:00"), title="Washington's Birthday", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Washington's Birthday")
- // Memorial Day
- _date := input.time(timestamp("30 May 2022 05:00"), title="Memorial Day", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Memorial Day")
- // Juneteenth National Independence Day
- _date := input.time(timestamp("19 Jun 2022 05:00"), title="Juneteenth Independence Day", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Juneteenth National Independence Day")
- // Juneteenth National Independence Day
- _date := input.time(timestamp("4 Jul 2022 05:00"), title="Independence Day", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Independence Day")
- // Labor Day
- _date := input.time(timestamp("5 Sep 2022 05:00"), title="Labor Day", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Labor Day")
- // Veterans Day US
- _date := input.time(timestamp("9 Nov 2022 05:00"), title="Veterans Day US", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Veterans Day US")
- // Thanksgiving
- _date := input.time(timestamp("24 Nov 2022 05:00"), title="Thanksgiving", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Thanksgiving")
- // Christmas Day
- _date := input.time(timestamp("25 Dec 2022 05:00"), title="Christmas Day", group="US Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Christmas Day")
- // UK HOLIDAYS
- // Queen II Funeral UK
- array.push(hYear, 2022)
- array.push(hMonth, 9)
- array.push(hDay, 19)
- array.push(hName, "Queen II Funeral")
- // New Years Day
- _date := input.time(timestamp("3 Jan 2022 05:00"), title="New Year's Day", group="UK Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "New Year's Day")
- // Good Friday
- _date := input.time(timestamp("15 Apr 2022 05:00"), title="Good Friday", group="UK Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Good Friday")
- // Easter Monday
- _date := input.time(timestamp("18 Apr 2022 05:00"), title="Easter Monday", group="UK Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Easter Monday")
- // Early May
- _date := input.time(timestamp("2 May 2022 05:00"), title="Early May", group="UK Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Early May")
- // Spring Bank Holiday
- _date := input.time(timestamp("2 Jun 2022 05:00"), title="Spring Bank Holiday", group="UK Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Spring Bank Holiday")
- // Summer Bank Holiday
- _date := input.time(timestamp("29 Aug 2022 05:00"), title="Summer Bank Holiday", group="UK Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Summer Bank Holiday")
- // Christmas Day
- _date := input.time(timestamp("27 Dec 2022 05:00"), title="Christmas Day", group="UK Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Christmas Day")
- // Boxing Day
- _date := input.time(timestamp("28 Dec 2022 05:00"), title="Boxing Day", group="UK Holidays")
- _year := year(_date)
- _month := month(_date)
- _day := dayofmonth(_date)
- array.push(hYear, _year)
- array.push(hMonth, _month)
- array.push(hDay, _day)
- array.push(hName, "Boxing Day")
- pYear = 0
- pMonth = 0
- pDay = 0
- pName = ""
- t = time(timeframe.period, "0000-0001")
- for i = 0 to array.size(hYear) -1
- pYear := array.get(hYear, i)
- pMonth := array.get(hMonth, i)
- pDay := array.get(hDay, i)
- pName := array.get(hName, i)
- if year == pYear and month == pMonth and dayofmonth == pDay and holidayShow
- bgColor := holidayColor
- if year == pYear and month == pMonth and dayofmonth == pDay and (not na(t)) and holidayShow
- label.new(bar_index, high, pName, color=color.blue, textcolor=color.white, yloc=yloc.abovebar)
- bgcolor(bgColor)
Advertisement
Add Comment
Please, Sign In to add comment