cTrader Integration
Pause order entry around scheduled economic releases and plot official macroeconomic series
under your cTrader charts. Two C# files, pasted straight into cTrader Automate:
FXMacroDataNewsFilter.cs
(a cBot) and
FXMacroDataIndicatorOverlay.cs
(a custom indicator). Both use cTrader's built-in HTTP API and the
System.Text.Json
namespace that ships with the cTrader Automate runtime. No NuGet packages, no DLLs.
Language
C# (cTrader Automate)
Authentication
API Key parameter
HTTP method
cTrader Http API
Files
Download
Each file is a complete, self-contained cTrader Automate source file. Download the one you need, or both, and paste its contents into a new cBot or indicator as shown in the setup guide.
FXMacroDataNewsFilter.cs
News filter cBot
Loads the FXMacroData release calendar for the currencies you choose and blocks new orders inside a configurable window around each scheduled release. Optionally closes open positions when a window opens. Create it as New › cBot.
Download .csFXMacroDataIndicatorOverlay.cs
Macro indicator panel
Fetches one macroeconomic series, for example USD inflation or EUR policy rate, and plots it as a step line on a separate panel below the price chart, aligned to each release date. Create it as New › Indicator.
Download .csInstallation
Setup guide
Open cTrader Automate
In the cTrader desktop application open the Automate section (shown as Algo in newer builds). The built-in editor opens with your existing cBots and indicators listed on the left.
Create the cBot or indicator and paste the source
Choose New › cBot for the news filter or New › Indicator for the macro panel.
Name it after the file, select all of the template code in the editor, delete it, and paste the full
contents of the downloaded file. The file type must match: the news filter is a
Robot, the overlay is an
Indicator.
Build
Press F6 or click Build. The output panel reports Build succeeded. Both files compile with no additional references.
Add it to a chart
Open any chart, then add an instance from the Automate panel (or drag the cBot or indicator onto the chart).
The parameter panel opens. Both files use cTrader's network API under
AccessRights.None,
so no additional access permission is needed. See
Access rights below.
Set the parameters and start
For the news filter set Currencies (for example USD,EUR)
and the block window, then click Start. For the indicator set Currency and
Indicator (for example USD and
inflation), then click OK.
Enter your API key in the
API Key field for any currency other than USD.
Check the log
Open the Log tab in cTrader Automate. Every fetch and every blocking window is printed there.
FXMacroDataNewsFilter.cs
News filter cBot
On start, and again every refresh interval, the cBot requests the release calendar for each configured currency from
GET https://fxmacrodata.com/api/v1/calendar/{currency}
and keeps every future announcement_datetime.
On every tick it checks whether the current UTC time falls inside the window around any tracked release.
| Parameter | Type | Default | Description |
|---|---|---|---|
| API Key | string | "" | Your FXMacroData API key. Leave blank for the USD calendar. Required for every other currency. |
| Currencies (comma-separated) | string | USD | Calendars to monitor, for example USD,EUR,GBP. Match the currencies of the symbol you trade. |
| Minutes to Block Before Release | int | 15 | Start of the blocking window, in minutes before each scheduled release. Range 1 to 240. |
| Minutes to Block After Release | int | 15 | End of the blocking window, in minutes after each scheduled release. Range 1 to 240. |
| Close Positions During Block | bool | false | When true, closes every open position on the account the moment a blocking window starts. |
| Calendar Refresh Interval (minutes) | int | 60 | How often the calendar is fetched again. Range 10 to 1440. Longer intervals use fewer requests. |
Public methods
| Method | Returns | Description |
|---|---|---|
| IsBlockingPeriod() | bool | True while the current UTC time is inside a blocking window around any tracked release. This is the gate to call before placing an order. |
| NextRelease() | DateTimeOffset? | UTC timestamp of the next scheduled release, or null when none are loaded. |
On the chart, the cBot draws each release of the next seven days as a line at the release time with the blocking window shaded, and keeps a fixed panel in the top-left corner showing the filter status and the next five releases with their UTC times and countdowns. Both are removed when the cBot stops. The API key is remembered for the cBot on your computer after the first run, so the field can be left blank afterwards.
Some publishers announce a release date before they announce its time. Those calendar rows carry
time_announced: false and a midnight local timestamp, so a
date-only release blocks around 00:00 in the publisher's timezone until the exact time is published and the row is replaced.
Field reference: response fields.
FXMacroDataIndicatorOverlay.cs
Macro indicator panel
The indicator fetches one series from
GET https://fxmacrodata.com/api/v1/announcements/{currency}/{indicator}
when it loads. Each bar shows the latest observation whose period date is on or before that bar's date, giving a
step-function view of the macro series against price. It plots on its own panel below the price chart.
| Parameter | Type | Default | Description |
|---|---|---|---|
| Currency | string | USD | 3-letter currency code, for example USD, EUR, GBP, JPY. |
| Indicator | string | inflation | Indicator slug, for example inflation, gdp, policy_rate, unemployment. |
| API Key | string | "" | Your FXMacroData API key. Required for every currency other than USD. |
| Start Date (YYYY-MM-DD) | string | "" | Earliest period date to fetch. Blank uses the API default range. |
| End Date (YYYY-MM-DD) | string | "" | Latest period date to fetch. Blank means today. |
Output
Value: one line series, thickness 2- Separate panel below the price chart, auto-rescaled
- Step-filled to the nearest earlier bar
Common slugs
Not every indicator is available for every currency. Coverage for all 22 currencies:
fxmacrodata.com/documentation/reference.
To compare two series, add a second instance of the indicator, for example EUR and USD
policy_rate on a EURUSD chart.
Example
Guard your own cBot
The gate is the IsBlockingPeriod() method.
To use it inside an existing strategy, copy the calendar section of
FXMacroDataNewsFilter.cs
into your cBot: the [Parameter] declarations,
the ApiBase,
_releaseTimes and
_calendars fields, the
_lastRefresh fields, and the
RefreshCalendar,
FetchCalendar and
IsBlockingPeriod methods.
Then check the gate before every order.
using System; using cAlgo.API; [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class MyStrategy : Robot { // Calendar fields, parameters and methods copied from FXMacroDataNewsFilter.cs protected override void OnStart() { RefreshCalendar(); } protected override void OnBar() { if ((DateTime.UtcNow - _lastRefresh).TotalMinutes >= RefreshIntervalMinutes) RefreshCalendar(); if (IsBlockingPeriod()) { Print("Scheduled release window is open, skipping entry."); return; } if (EntrySignal()) ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000); } private bool EntrySignal() { // Your own entry logic return false; } }
Set Currencies to both sides of the symbol you trade, for example
GBP,JPY for GBPJPY, so Bank of England and Bank of Japan releases both gate entries.
Permissions
Access rights
Both files declare AccessRights.None
and call the API through cTrader's built-in Http API.
Outbound HTTPS requests to fxmacrodata.com
work without granting full access. No other host is contacted.
Each request carries only that instance's API key in the
X-API-Key header.
See the cTrader network access guide
for the platform's network permissions.
Keys
Authentication
Without a key
- USD release calendar
- USD announcement series, most recent 90 days
- Up to 100 requests per day
- Releases visible 15 minutes after publication
With an Individual or Business key
- All 22 currencies, calendars and full series history
- Releases in real time, no delay
- Plan rate limits in place of the evaluation cap
Create a key at fxmacrodata.com/subscribe and manage it in
API Management. Paste it into the
API Key parameter of each instance; the files send it with every request.
Keep the key out of shared screenshots and chart templates.
Help
Troubleshooting
Build fails with a missing namespace or attribute error
The file type does not match the project type. FXMacroDataNewsFilter.cs
must be created with New › cBot and FXMacroDataIndicatorOverlay.cs
with New › Indicator. Also make sure the whole template was deleted before pasting, so the file starts with the
using directives.
The log shows a 401 Unauthorized error
A currency other than USD was requested without a valid key. Check the API Key
parameter for extra spaces, confirm the key is active in API Management,
or remove the non-USD currencies to run keyless.
The log shows a 404 Not Found error
The currency code or indicator slug is not recognised, or that indicator is not published for that currency. Check the catalogue and use the slug exactly as listed, in lowercase with underscores.
The cBot never blocks, or reports 0 upcoming releases
Only releases with an official future schedule are tracked. Confirm the currency codes are spelled correctly and separated by commas, and that the first log line reports the calendar loaded. The calendar is in UTC and the cBot compares against UTC, so no timezone setting is needed.
The indicator panel is empty
Values are written to the bars loaded on the chart when the indicator initialises. If the chart's history does not reach back to the
fetched period dates, scroll the chart back to load more bars and re-add the indicator, or set a later
Start Date. Monthly and quarterly series look best on daily or weekly charts.
The indicator fetches once on load; change any parameter to fetch again.
Requests time out or return no data
Make sure your firewall allows outbound HTTPS from cTrader to
fxmacrodata.com, then restart the instance.
No full-access permission is required. See Access rights.
Positions closed unexpectedly
Close Positions During Block closes every open position on the account, not only
positions on the chart's symbol, when a window starts. Leave it false unless that is what you want,
and test on a demo account first.