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.
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
A small Python relay that sits between your TradingView alert webhook and your broker bridge or bot. It drops or holds alerts inside a window around each scheduled tier-1 release.
ChartsPine Script v6 templates
A ready-made Release Markers indicator with the tier-1 schedule embedded, plus templates for rate differentials, inflation backgrounds, macro scores and yield spreads that take official values as inputs.
AI assistantsTradingView MCP + FXMacroData MCP
Connect both MCP servers to Claude or ChatGPT. The assistant reads your TradingView watchlists and bars, and FXMacroData supplies exact release times, published values and revisions.
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).
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.
What happens to each alert
| Situation | Decision |
|---|---|
| No tier-1 release near for the alert's currencies | forward: posted unchanged to your target URL |
Inside the window, mode drop | drop: acknowledged to TradingView, nothing forwarded |
Inside the window, mode hold | hold: forwarded when the window closes, up to the hold cap |
| Ticker not recognised | forward 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.pinePaste 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 |
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
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
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}
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.
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
API: /v1/announcements/usd/gov_bond_10y · /v1/announcements/eur/gov_bond_10y · and more
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.
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
| TradingView | FXMacroData |
|---|---|
| Your watchlists and symbols | Exact scheduled release instants per currency |
| OHLCV bars and technical ratings | Published values, publication timestamps and revisions |
| Price alerts you can create from chat | Policy rates, CPI, GDP, labour data for 22 currencies |
| TradingView's economic series by country | Official-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)
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_rateCentral bank policy raterisk_free_rateOvernight risk-free rategov_bond_2y2-year government yieldgov_bond_10y10-year government yieldinflation_linked_bondReal yield proxy
Macro fundamentals
inflationCPI year-on-yearcore_inflationCore CPI (ex food/energy)unemploymentUnemployment rategdpGDP (headline series: a level or a growth rate, depending on the country)trade_balanceTrade 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.