//@version=5
indicator("FOMC Event Marker", overlay=true, max_lines_count=500, max_labels_count=500)
// Dates are interpreted in the selected timezone.
fomcDatesInput = input.string(
"2024-01-31,2024-03-20,2024-05-01,2024-06-12,2024-07-31",
"FOMC Dates (comma-separated)"
)
eventTimezone = input.string("America/New_York", "Event Timezone")
showLines = input.bool(true, "Show Vertical Lines")
showLabels = input.bool(true, "Show Labels")
showBg = input.bool(true, "Highlight Background")
showShapes = input.bool(true, "Show Markers")
fomcDates = str.split(fomcDatesInput, ",")
isFomcDay() =>
bool matched = false
int currentDay = timestamp(
eventTimezone,
year(time, eventTimezone),
month(time, eventTimezone),
dayofmonth(time, eventTimezone),
0,
0
)
for dateText in fomcDates
string cleanDate = str.trim(dateText)
array<string> parts = str.split(cleanDate, "-")
if array.size(parts) == 3
int eventYear = int(str.tonumber(array.get(parts, 0)))
int eventMonth = int(str.tonumber(array.get(parts, 1)))
int eventDay = int(str.tonumber(array.get(parts, 2)))
int eventDate = timestamp(
eventTimezone,
eventYear,
eventMonth,
eventDay,
0,
0
)
if currentDay == eventDate
matched := true
matched
bool fomcDay = isFomcDay()
// Create one line and label at the first bar of each FOMC day.
bool firstFomcBar = fomcDay and (not fomcDay[1] or timeframe.change("D"))
if firstFomcBar
if showLines
line.new(
bar_index,
low,
bar_index,
high,
color=color.orange,
width=1,
extend=extend.both
)
if showLabels
label.new(
bar_index,
high,
"FOMC",
style=label.style_label_down,
color=color.orange,
textcolor=color.white,
size=size.small
)
bgcolor(showBg and fomcDay ? color.new(color.orange, 80) : na)
plotshape(
showShapes and firstFomcBar,
title="FOMC Day",
style=shape.triangleup,
location=location.top,
color=color.orange,
size=size.tiny
)