Skip to content
Webhook news filter Pine Script v6 MCP

FXMacroData for TradingView

Pause your TradingView strategy alerts around scheduled releases, put official policy rates and inflation prints on your charts with Pine Script, and let an AI assistant combine TradingView's tools with FXMacroData release times.

3 integration routes
https://api.fxmacrodata.com/v1/
Official release times only

Pine Script cannot call an external API

TradingView's Pine Script is sandboxed: it has no HTTP access and can only read data that TradingView itself hosts. FXMacroData values cannot be fetched live inside a Pine indicator. Each route below works around that limit in a different way: the news filter runs outside TradingView and acts on its alerts, the Pine templates take official values as inputs, and the MCP route lets an assistant query both systems side by side.

Three ways to use FXMacroData with TradingView

Pick the one that matches how you use TradingView today.

Webhook news filter for TradingView strategies

TradingView alerts can POST to any public HTTPS URL. Point them at the filter instead of your broker bridge, and the filter forwards, drops or holds each alert depending on the FXMacroData release calendar.

Download and run the filter

Python 3.10 or newer, no dependencies. Unzip the package and start it with the URL your alerts currently post to (a TradersPost or PickMyTrade webhook, a self-hosted bot, any HTTPS endpoint).

# USD releases, drop alerts from 10 minutes before to 10 minutes after each one python -m fxmd_tv_newsfilter --forward-url "https://your-bridge.example/webhook/abc123" --currencies USD # EUR and GBP as well (needs an API key), hold alerts instead of dropping them set FXMD_API_KEY=YOUR_API_KEY python -m fxmd_tv_newsfilter --forward-url "https://your-bridge.example/webhook/abc123" --currencies USD,EUR,GBP --mode hold --before-min 15 --after-min 15

Give it a public HTTPS address

TradingView must be able to reach the filter, so expose it the same way you expose any webhook receiver: a small VPS, Cloudflare Tunnel, or your existing reverse proxy. Set FXMD_TV_SECRET so the alert path carries a secret segment that only TradingView knows.

Point your TradingView alert at it

In the alert dialog, enable Webhook URL and paste the filter's address. Keep the alert message as JSON that names the ticker, so the filter knows which currencies the trade touches. Webhook alerts need a paid TradingView plan.

{ "ticker": "{{ticker}}", "action": "{{strategy.order.action}}", "contracts": "{{strategy.order.contracts}}", "price": "{{close}}", "time": "{{timenow}}" }

What happens to each alert

SituationDecision
No tier-1 release near for the alert's currenciesforward: posted unchanged to your target URL
Inside the window, mode dropdrop: acknowledged to TradingView, nothing forwarded
Inside the window, mode holdhold: forwarded when the window closes, up to the hold cap
Ticker not recognisedforward by default; set FXMD_TV_UNKNOWN_SYMBOL=drop to fail closed

How the calendar is read

The filter loads /v1/calendar/{currency} once an hour and keeps only rows whose exact release time has been announced by the publisher. Date-only entries and assumed times are never used for a minute-precision window.

By default it uses tier-1 releases: policy decisions, CPI, GDP, labour market and retail sales, plus the handful of releases that are top tier for a specific currency. FXMD_TV_IMPORTANCE=medium or all widens it.

Tickers map to currencies automatically: FX pairs to both legs, gold and silver to USD, US500 and NAS100 to USD, DE40 to EUR, UK100 to GBP, JP225 to JPY, crypto pairs to the fiat quote.

Flatten positions before a release, with or without an alert

Set FXMD_TV_FLATTEN_URL to a TradersPost-style webhook and FXMD_TV_FLATTEN_TICKERS to the symbols you trade, and the filter posts an exit-and-cancel payload for each ticker a few minutes before any selected release that touches its currencies. The payload template is configurable for other bridges, and --dry-run prints the planned flatten times first.

USD calendars work without a key. Other currencies need an Individual or Business key, read from FXMD_API_KEY and sent as a header, never in a URL. The filter does not place trades; it only decides whether your alert reaches the system that does. The same pattern is available as a cTrader cBot.

Release Markers indicator

A ready-made Pine Script v6 indicator with the next months of tier-1 releases embedded as exact official release instants. No values to type in and no library to install: one file, pasted once, on any TradingView plan.

Download the file

The schedule inside it covers about four months from the generation date shown in the file header, for USD, EUR, GBP, JPY, AUD, CAD, CHF and NZD. A fresh copy is published every month; download it again to extend the horizon.

Download FXMacroDataReleaseMarkers.pine

Paste it into Pine Editor

Open any chart, open the Pine Editor panel, create a new blank indicator, replace its contents with the file, and click Add to chart. Save it to keep it in your indicator list.

Choose currencies and windows

In the indicator settings set the currencies you trade (default USD, EUR, GBP, JPY) and the blackout minutes before and after each release. Create an alert on the indicator and pick "Tier-1 release within N minutes" or "Blackout active".

What it draws

Dashed vertical line and label on the bar containing each release, for example "USD CPI" or "EUR Rate decision"
Dotted lines to the right of the last bar for releases still ahead
Shaded blackout band around every selected release
Top-right panel with the next release, its UTC time and whether a blackout is active
Two alert conditions driven by the wall clock, so they fire between bars on slow timeframes
Only releases whose exact time the publisher has announced are included. The file holds times, not values. The same schedule drives the webhook news filter above, so chart markers and blocked alerts always agree.

Pine Script v6 templates

Each template takes official values as indicator inputs. Fetch the latest reading, paste the script into Pine Editor, add it to the chart, and enter the numbers in the settings panel. Refresh them after the next release.

Policy Rate Differential

Draws a reference line and a small table for the base/quote central bank rate spread. Works on any FX pair. Data source: /v1/announcements/{currency}/policy_rate

// FXMacroData: Policy Rate Differential // Source: https://api.fxmacrodata.com/v1/announcements/{currency}/policy_rate //@version=6 indicator("FXMacroData: Policy Rate Differential", overlay = true, max_lines_count = 10, max_labels_count = 10) // Inputs: enter the latest values from FXMacroData base_rate = input.float(5.25, "Base currency rate (%)", step = 0.25) quote_rate = input.float(4.50, "Quote currency rate (%)", step = 0.25) show_label = input.bool(true, "Show differential label") diff = base_rate - quote_rate col = diff > 0 ? color.teal : color.red // Reference line at the current close, redrawn on the last bar var line ref_line = na var label ref_label = na if barstate.islast line.delete(ref_line) ref_line := line.new(bar_index - 1, close, bar_index, close, extend = extend.right, color = col, width = 2, style = line.style_dotted) label.delete(ref_label) if show_label ref_label := label.new(bar_index, close, "Rate diff: " + str.tostring(diff, "#.##") + "%", style = label.style_label_left, color = col, textcolor = color.white, size = size.small) // Table overlay var table tbl = table.new(position.top_right, 2, 3, bgcolor = color.new(color.white, 10), border_width = 1) if barstate.islast table.cell(tbl, 0, 0, "Base rate", text_color = color.gray, text_size = size.small) table.cell(tbl, 1, 0, str.tostring(base_rate) + "%", text_color = color.black, text_size = size.small) table.cell(tbl, 0, 1, "Quote rate", text_color = color.gray, text_size = size.small) table.cell(tbl, 1, 1, str.tostring(quote_rate) + "%", text_color = color.black, text_size = size.small) table.cell(tbl, 0, 2, "Differential", text_color = color.gray, text_size = size.small) table.cell(tbl, 1, 2, str.tostring(diff, "#.##") + "%", text_color = col, text_size = size.small)

API endpoints: /v1/announcements/usd/policy_rate · /v1/announcements/eur/policy_rate · and 20 more currencies

Inflation Differential

Shades the chart background by which side of the pair has inflation above target. Data source: /v1/announcements/{currency}/inflation

// FXMacroData: Inflation Differential Background // Source: https://api.fxmacrodata.com/v1/announcements/{currency}/inflation //@version=6 indicator("FXMacroData: Inflation Differential", overlay = true, max_labels_count = 10) base_cpi = input.float(3.5, "Base CPI YoY (%)", step = 0.1) quote_cpi = input.float(2.9, "Quote CPI YoY (%)", step = 0.1) target = input.float(2.0, "Central bank target (%)", step = 0.1) opacity = input.int(88, "Background transparency (0-100)", minval = 0, maxval = 100) diff = base_cpi - quote_cpi base_hot = base_cpi > target quote_hot = quote_cpi > target bg_col = base_hot and quote_hot ? color.new(color.orange, opacity) : base_hot ? color.new(color.red, opacity) : quote_hot ? color.new(color.blue, opacity) : color.new(color.green, opacity) bgcolor(bg_col) var label lbl = na if barstate.islast label.delete(lbl) lbl := label.new(bar_index, high, "CPI diff: " + str.tostring(diff, "#.#") + "%\nBase: " + str.tostring(base_cpi) + "% | Quote: " + str.tostring(quote_cpi) + "%", style = label.style_label_down, color = color.new(bg_col, 0), textcolor = color.white, size = size.normal)

API endpoints: /v1/announcements/usd/inflation · and 21 more currencies

Macro Strength Score

A four-factor composite for a currency pair in a separate pane. Pull all four from /v1/announcements/{currency}/{indicator}

// FXMacroData: Macro Strength Score (4-factor composite) // Indicators: policy_rate, inflation, unemployment, gdp //@version=6 indicator("FXMacroData: Macro Strength Score", overlay = false) b_rate = input.float(5.25, "Policy rate (%)", group = "Base currency", step = 0.25) b_cpi = input.float(3.5, "CPI YoY (%)", group = "Base currency", step = 0.1) b_unemp = input.float(3.9, "Unemployment (%)", group = "Base currency", step = 0.1) b_gdp = input.float(2.8, "GDP YoY (%)", group = "Base currency", step = 0.1) q_rate = input.float(4.50, "Policy rate (%)", group = "Quote currency", step = 0.25) q_cpi = input.float(2.9, "CPI YoY (%)", group = "Quote currency", step = 0.1) q_unemp = input.float(4.3, "Unemployment (%)", group = "Quote currency", step = 0.1) q_gdp = input.float(1.4, "GDP YoY (%)", group = "Quote currency", step = 0.1) // Higher rate, higher CPI, lower unemployment and higher growth favour the base currency rate_score = b_rate - q_rate cpi_score = b_cpi - q_cpi unemp_score = q_unemp - b_unemp gdp_score = b_gdp - q_gdp composite = rate_score * 1.5 + cpi_score + unemp_score + gdp_score hline(0, "Neutral", color = color.gray, linestyle = hline.style_dotted) plot(composite, "Macro score", color = composite > 0 ? color.teal : color.red, style = plot.style_columns, linewidth = 2)

Combine policy_rate, inflation, unemployment, and gdp across any currency pair.

Economic Release Labels

Marks the bar in which a scheduled release happened and labels it with actual, forecast and previous. Use /v1/calendar/{currency} for the exact release time.

// FXMacroData: Economic Release Label // Source: https://api.fxmacrodata.com/v1/calendar/{currency} //@version=6 indicator("FXMacroData: Economic Release Labels", overlay = true, max_labels_count = 20) release_time = input.time(timestamp("UTC", 2026, 1, 13, 13, 30), "Release time (UTC)") release_label = input.string("USD CPI", "Release label") actual = input.float(3.1, "Actual (%)", step = 0.1) forecast = input.float(3.0, "Forecast (%)", step = 0.1) previous = input.float(3.2, "Previous (%)", step = 0.1) beat = actual > forecast col = beat ? color.teal : color.red // The release falls inside this bar when its time is between the bar open and close if time <= release_time and time_close > release_time label.new(bar_index, low, release_label + "\n" + str.tostring(actual) + "% (f: " + str.tostring(forecast) + "% / p: " + str.tostring(previous) + "%)", style = beat ? label.style_label_up : label.style_label_down, color = col, textcolor = color.white, size = size.small)

Release times come from the release calendar endpoint or the release calendar dashboard. For many releases at once, use the news filter above instead of typing them in.

Yield Spread

Plots a 10-year government bond yield spread between two countries in a separate pane. Data source: /v1/announcements/{currency}/gov_bond_10y

// FXMacroData: 10Y Government Bond Yield Spread // Source: https://api.fxmacrodata.com/v1/announcements/{currency}/gov_bond_10y //@version=6 indicator("FXMacroData: 10Y Yield Spread", overlay = false) base_yield = input.float(4.60, "Base 10Y yield (%)", step = 0.01) quote_yield = input.float(3.20, "Quote 10Y yield (%)", step = 0.01) spread = base_yield - quote_yield hline(0, "Zero", color = color.gray, linestyle = hline.style_dotted) plot(spread, "10Y spread", color = spread > 0 ? color.teal : color.red, linewidth = 2) var table tbl = table.new(position.bottom_right, 2, 2, bgcolor = color.new(color.white, 15), border_width = 1) if barstate.islast table.cell(tbl, 0, 0, "Base 10Y", text_color = color.gray) table.cell(tbl, 1, 0, str.tostring(base_yield, "#.##") + "%") table.cell(tbl, 0, 1, "Quote 10Y", text_color = color.gray) table.cell(tbl, 1, 1, str.tostring(quote_yield, "#.##") + "%")

Fetching values for the templates

Get the latest reading before opening your TradingView chart. USD endpoints support no-key evaluation up to 100 requests/day, 15 minutes behind publication; an Individual or Business key returns releases in real time.

# Latest USD policy rate (no-key evaluation, up to 100 requests/day) curl "https://api.fxmacrodata.com/v1/announcements/usd/policy_rate" # Latest EUR inflation (requires an API key) curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/announcements/eur/inflation" # Upcoming USD releases with exact times, for the Release Labels template curl "https://api.fxmacrodata.com/v1/calendar/usd"

TradingView MCP and FXMacroData MCP together

TradingView publishes its own MCP server for watchlists, bars, screener, news and alerts. Connect it next to the FXMacroData MCP server and one assistant can answer questions that need both: what you are watching, and what is about to be released.

What each server brings

TradingViewFXMacroData
Your watchlists and symbolsExact scheduled release instants per currency
OHLCV bars and technical ratingsPublished values, publication timestamps and revisions
Price alerts you can create from chatPolicy rates, CPI, GDP, labour data for 22 currencies
TradingView's economic series by countryOfficial-source history with release timing fields

TradingView's MCP server is included with its Essential plan and above and signs in with your TradingView account. The FXMacroData server works without a key for USD and takes an API key for other currencies.

Client configuration (Streamable HTTP)

{ "mcpServers": { "tradingview": { "type": "http", "url": "https://mcp.tradingview.com/mcp" }, "fxmacrodata": { "type": "http", "url": "https://mcp.fxmacrodata.com", "headers": { "Authorization": "Bearer YOUR_API_KEY" } } } }

In Claude and ChatGPT add each URL as a custom connector instead of editing a file. Full client list: MCP server documentation.

Prompts that use both servers

  • 1"Read my TradingView watchlist and tell me which pairs have a tier-1 release in the next 24 hours, with the exact UTC time from FXMacroData."
  • 2"Find the next US CPI release time in FXMacroData, then create a TradingView price alert on EURUSD at the current price so I am notified if it moves before the print."
  • 3"Compare TradingView's US CPI series with the FXMacroData inflation history for the last 12 months and list any months where the two values differ or FXMacroData shows a revision."
  • 4"Pull the last 30 daily EURUSD bars from TradingView and mark which days had an ECB or Federal Reserve decision according to the FXMacroData calendar."

TradingView alerts created through its MCP server are simple price conditions; time-based alerts and webhook alerts are set up in TradingView itself.

Indicators used most with these templates

All available via /v1/announcements/{currency}/{indicator}

Monetary policy

  • policy_rate Central bank policy rate
  • risk_free_rate Overnight risk-free rate
  • gov_bond_2y 2-year government yield
  • gov_bond_10y 10-year government yield
  • inflation_linked_bond Real yield proxy

Macro fundamentals

  • inflation CPI year-on-year
  • core_inflation Core CPI (ex food/energy)
  • unemployment Unemployment rate
  • gdp GDP (headline series: a level or a growth rate, depending on the country)
  • trade_balance Trade balance

Full indicator list: API documentation · Full endpoint reference per currency: Indicator index

Tips and limitations

Template values update only when you change the input

Pine inputs are static. The indicator shows the same values until you open its settings and update them, so refresh them after each central bank meeting or major release. The release calendar tells you exactly when that is.

The news filter needs exact release times

A publisher that has announced only the date, not the time, produces a calendar row the filter ignores on purpose. That is deliberate: a window built around an assumed time would block the wrong minutes. Such rows are replaced by timed rows as soon as the publisher confirms the time.

Keep keys out of alert messages

TradingView alert messages are not secret. Your FXMacroData key belongs in the filter's environment on your server, never in the alert text or the webhook URL.

Get started

Ready to add macro context to your TradingView workflow?

USD calendars and indicators support no-key evaluation up to 100 requests/day. Subscribe for real-time releases and all 22 currencies.

AI Answer-Ready

Key Facts

Page
Pine Script
Section
Documentation
Canonical URL
https://fxmacrodata.com/documentation/pine-script
Source
FXMacroData editorial and official publisher references
Last Updated
See page metadata

Provenance And Trust

Cite the canonical URL and source field above. Where available, this page maps to official publisher releases and timestamped updates.

Quick Q&A

What is this page about? This page explains Pine Script with directly usable context for trading, research, and API workflows.

What source should be cited? Use the canonical URL and the listed source field; cite official publisher references when available.

How fresh is this content? The last updated value above reflects the page metadata or latest available data timestamp.

Can this be used in AI assistants? Yes. This section is intentionally structured for retrieval and citation in chat assistants.

Prompt Packs

Use these in ChatGPT, Claude, Gemini, Mistral, Perplexity, or Grok for consistent source-aware outputs.

Share page X LinkedIn Email