本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("FOMC Decision Days (2024 - now)", overlay = true, max_labels_count = 500, max_lines_count = 500)
// ── Inputs ────────────────────────────────────────────────
showToday = input.bool(true, "Include Oct 28, 2026 (decision 2:00 PM ET today)")
showLbl = input.bool(true, "Show labels")
showRange = input.bool(true, "Show target range in label")
showLine = input.bool(true, "Show vertical lines")
showBg = input.bool(false, "Highlight background")
cHold = input.color(color.gray, "Hold color")
cCut = input.color(color.green, "Cut color")
cHike = input.color(color.red, "Hike color")
cPend = input.color(color.orange, "Pending color")
// ── FOMC decision days (YYYYMMDD), action, target range after ──
var array<int> fomc = array.from(
20240131, 20240320, 20240501, 20240612, 20240731, 20240918, 20241107, 20241218,
20250129, 20250319, 20250507, 20250618, 20250730, 20250917, 20251029, 20251210,
20260128, 20260318, 20260429, 20260617, 20260729, 20260916, 20261028)
var array<string> act = array.from(
"Hold", "Hold", "Hold", "Hold", "Hold", "Cut 50bp", "Cut 25bp", "Cut 25bp",
"Hold", "Hold", "Hold", "Hold", "Hold", "Cut 25bp", "Cut 25bp", "Cut 25bp",
"Hold", "Hold", "Hold", "Hold", "Hold", "Hike 25bp", "Pending")
var array<string> rng = array.from(
"5.25-5.50%", "5.25-5.50%", "5.25-5.50%", "5.25-5.50%", "5.25-5.50%", "4.75-5.00%", "4.50-4.75%", "4.25-4.50%",
"4.25-4.50%", "4.25-4.50%", "4.25-4.50%", "4.25-4.50%", "4.25-4.50%", "4.00-4.25%", "3.75-4.00%", "3.50-3.75%",
"3.50-3.75%", "3.50-3.75%", "3.50-3.75%", "3.50-3.75%", "3.50-3.75%", "3.75-4.00%", "2:00 PM ET")
// Trading day of each bar (works on intraday and daily charts, stocks and crypto)
d = year(time_tradingday, "UTC") * 10000 + month(time_tradingday, "UTC") * 100 + dayofmonth(time_tradingday, "UTC")
idx = array.indexof(fomc, d)
isFomc = idx >= 0 and (showToday or d != 20261028)
firstBar = isFomc and (na(d[1]) or d != d[1])
colorFor(string a) =>
str.startswith(a, "Cut") ? cCut : str.startswith(a, "Hike") ? cHike : a == "Pending" ? cPend : cHold
if firstBar
a = array.get(act, idx)
clr = colorFor(a)
if showLine
line.new(bar_index, low, bar_index, high, extend = extend.both, color = color.new(clr, 40), style = line.style_dashed)
if showLbl
dt = str.tostring(month(time_tradingday, "UTC")) + "/" + str.tostring(dayofmonth(time_tradingday, "UTC")) + "/" + str.tostring(year(time_tradingday, "UTC") % 100)
txt = "FOMC " + dt + "\n" + a + (showRange ? "\n" + array.get(rng, idx) : "")
label.new(bar_index, high, txt, yloc = yloc.abovebar, style = label.style_label_down, color = clr, textcolor = color.white, size = size.small)
bgcolor(showBg and isFomc ? color.new(colorFor(array.get(act, idx)), 85) : na)