cTrader Open API is a developer surface for building trading applications connected to the cTrader backend. FXMacroData fits beside it as the pre-trade macro layer: release calendars, announcement history, EUR/USD context, FX sessions, and event windows that should be checked before an automated order reaches a broker account.
The integration is useful because a valid order message is not always a tradeable order. A EUR/USD signal can be technically valid but operationally poor during US CPI, Non-Farm Payrolls, or a Federal Reserve decision window. The broker connection should not have to understand that context. The service between your strategy and cTrader should.
Fit
Use this for
cTrader Open API applications that need a deterministic macro checkpoint before new order messages are sent.
cTrader works best when
It handles account, symbol, and trading messages while your execution service owns macro policy and audit state.
Avoid
Letting an assistant, notebook, or signal webhook send trade-permission order messages without a macro and risk gate.
Why cTrader Open API Fits Macro Gates
cTrader describes Open API as a way to build applications that send and receive information to and from the cTrader backend. The docs cover registered applications, OAuth-style account authorization, proxy endpoints, TCP or WebSocket connectivity, and JSON or Protobuf message formats. The important implementation point is that cTrader Open API is not a normal REST order endpoint. It is a message-based connection into a trading backend.
That makes the macro gate a clean separate layer. cTrader can keep doing what it is designed for: account authorization, symbol discovery, order messaging, position state, and trading-account responses. FXMacroData can answer a different question before the message is sent: is this order candidate happening inside a macro window where the strategy should wait, reduce size, or require review?
What Changes for the Trader
The desk gets an audit trail, not just a broker log. A cTrader message log can tell you that an order was accepted or rejected by the trading backend. A macro-aware execution log can tell you why an otherwise valid candidate was stopped before it became a trading message.
Trading desk scenario
A strategy proposes a EUR/USD buy order while a USD inflation release is approaching. The execution service checks the FXMacroData release calendar, finds an active USD macro window, and marks the cTrader order candidate as review. The service records the blocked ticket, symbol, planned side, size, and event reason before any trade-permission message is sent.
This also improves post-trade review. If the strategy misses a move because the gate paused it, that is measurable. If the strategy avoids a poor fill or a news spike, that is measurable too. The goal is not to block every release. The goal is to make event exposure explicit and reviewable.
Workflow Shape
1. Signal
A strategy, alert receiver, or analyst workflow creates an order candidate.
2. Context
The service fetches FXMacroData calendar, announcement, pair, and session context.
3. Gate
Policy decides whether the candidate is allow, wait, reduce, or review.
4. Message
Only approved tickets become cTrader Open API order messages.
5. Review
Allowed and blocked candidates are compared against later market outcomes.
Where Each Layer Belongs
| Layer | Use it for | Do not use it for |
|---|---|---|
| cTrader Open API | Registered apps, account authorization, symbol data, order messages, positions, and broker-side trading state. | Macro-event interpretation or storing FXMacroData credentials. |
| FXMacroData REST | Production macro checks against calendars, announcements, FX pair context, sessions, and event history. | Broker-side order submission or cTrader account authorization. |
| FXMacroData MCP | Research assistant workflows, blocked-order explanations, and strategy-review notebooks. | Real-time trade routing or account-token handling. |
| Execution service | Policy, secrets, retries, logging, and the final allow/review decision. | Hidden discretionary behavior buried inside prompts or notebooks. |
Prerequisites
- A cTrader ID and a registered Open API application.
- Approved redirect URIs and account authorization flow for the trading accounts your app will access.
- A decision on JSON versus Protobuf and TCP versus WebSocket for your cTrader client.
- An FXMacroData API key held server-side and passed as
?api_key=YOUR_API_KEYin examples. - A written policy for which events, sessions, symbols, and missing-data states should block or review orders.
Step 1: Separate App, Account, and Trading Permissions
cTrader's Open API docs separate application registration from account authorization. Your app credentials authorize the application connection, while the account token and account ID authorize access to a trader account. Trading messages then depend on the relevant account permissions.
Keep those responsibilities explicit in configuration. Do not pass broker credentials to research notebooks or AI assistants.
{
"ctrader": {
"environment": "demo",
"message_format": "protobuf",
"transport": "websocket",
"submit_orders": false
},
"macro_gate": "required_before_new_order"
}
The cTrader docs list separate live and demo endpoints, and separate ports for Protobuf and JSON. Use that separation deliberately. Build the macro gate in a non-live trading path first, then promote the exact same policy only after you have reviewed its decisions.
Step 2: Define the Macro Execution Policy
Start with one pair and one macro currency. The policy should be readable by a trader and testable by an engineer.
pair: EUR_USD
macro_currency: USD
block_before_minutes: 30
block_after_minutes: 10
events:
- inflation
- non_farm_payrolls
- policy_rate
missing_data_decision: review
Use four decisions rather than a single true or false result. allow means the order candidate can proceed. wait means a scheduled event window is active. reduce means size can be cut without rejecting the signal. review means the service needs a human or a separate research flow before it sends a trade-permission message.
Step 3: Fetch FXMacroData Context
Fetch the macro context before constructing the cTrader new-order message. A narrow first implementation can use the release calendar, relevant announcement family, current pair context, and session state.
curl "https://api.fxmacrodata.com/v1/calendar/usd?api_key=YOUR_API_KEY"
curl "https://api.fxmacrodata.com/v1/announcements/usd/inflation?api_key=YOUR_API_KEY"
curl "https://api.fxmacrodata.com/v1/forex/eur/usd?api_key=YOUR_API_KEY"
In code, normalize the cTrader symbol into the pair and macro currency that your policy understands. cTrader order messages use symbol IDs, so keep a symbol map inside the execution service and store the human pair beside the internal ID in your audit log.
import os
import requests
FXMD_ROOT = "https://api.fxmacrodata.com"
FXMD_API_KEY = os.environ["FXMD_API_KEY"]
def fxmd_get(path):
response = requests.get(
f"{FXMD_ROOT}{path}",
params={"api_key": FXMD_API_KEY},
timeout=5,
)
response.raise_for_status()
return response.json()
def macro_context_for_eurusd():
return {
"calendar": fxmd_get("/v1/calendar/usd"),
"inflation": fxmd_get("/v1/announcements/usd/inflation"),
"spot": fxmd_get("/v1/forex/eur/usd"),
}
Step 4: Gate the cTrader Order Candidate
The gate should run before your application creates or sends a cTrader ProtoOANewOrderReq or equivalent JSON message. Keep it ordinary code so it can be unit-tested and replayed.
def decide_candidate(context, policy):
if macro_data_missing(context):
return {"decision": "review", "reason": "Macro data unavailable"}
if has_blocked_event(context["calendar"], policy):
return {"decision": "wait", "reason": "Blocked USD macro window"}
if is_thin_session(context, policy):
return {"decision": "reduce", "reason": "Thin session risk"}
return {"decision": "allow", "reason": "No blocked macro window"}
candidate = {"pair": "EUR_USD", "side": "BUY", "units": 10000}
decision = decide_candidate(macro_context_for_eurusd(), policy)
Example decision output
{
"pair": "EUR_USD",
"side": "BUY",
"units": 10000,
"decision": "wait",
"reason": "Blocked USD macro window",
"checked_paths": [
"/v1/calendar/usd",
"/v1/announcements/usd/inflation"
]
}
Step 5: Submit Only Approved Orders
Only approved candidates should become cTrader order messages. The exact client code depends on whether your app uses the official SDKs, JSON messages, or Protobuf messages. The safety rule is independent of that choice: the macro decision comes first.
candidate = build_order_candidate(signal)
context = macro_context_for_eurusd()
decision = decide_candidate(context, policy)
if decision["decision"] == "allow":
message = build_ctrader_new_order_message(candidate)
ctrader_send(message)
elif decision["decision"] == "reduce":
smaller = reduce_order_size(candidate, factor=0.5)
ctrader_send(build_ctrader_new_order_message(smaller))
else:
write_order_journal(candidate, decision, context)
For cTrader, the broker-facing order object needs fields such as account ID, symbol ID, order type, trade side, volume, and optional order controls. Your macro gate should not rewrite those fields silently. It should either allow the candidate, reduce it through an explicit policy rule, or write a reviewed rejection.
| Metric | Why it matters | Review cadence |
|---|---|---|
| Allowed versus reviewed candidates | Shows whether the gate changes behavior often enough to matter. | Daily. |
| Post-release slippage | Shows whether the release window is too wide or too narrow. | Weekly. |
| Missing-data reviews | Shows whether operational failures are being hidden as trading decisions. | Every incident. |
| Reduced-size outcomes | Shows whether partial participation beats a full wait rule. | Monthly. |
Optional MCP Research Layer
FXMacroData MCP is useful when a person or assistant needs to investigate a blocked trade, compare event history, or explain why a policy fired. Keep it separate from the production order path. The execution service should use REST for deterministic checks; the research assistant can use MCP after the fact.
{
"servers": {
"FXMacroData": {
"type": "http",
"url": "https://mcp.fxmacrodata.com"
}
}
}
Simple split
- cTrader Open API: trading account and order-message layer.
- FXMacroData REST: production macro gate before order submission.
- FXMacroData MCP: assistant-led research, explanations, and replay analysis.
Operational Guardrails
- Require a macro decision for every order candidate before building the cTrader order message.
- Use demo and live cTrader connections as separate runtime environments.
- Log the FXMacroData paths, policy version, candidate order, and decision for every allow, reduce, wait, or review outcome.
- Fail closed to
reviewwhen macro data is unavailable, delayed, or inconsistent with the pair being traded. - Keep FXMacroData API keys, cTrader client secrets, account tokens, and trade permissions in server-side services only.
- Replay blocked candidates after major releases to tune windows without guessing.
What You Have Built
This pattern gives a cTrader Open API application a macro-aware checkpoint without confusing the broker layer with the data layer. cTrader remains responsible for account and trading messages. FXMacroData REST supplies the calendar, announcement, pair, and session evidence. MCP remains available for research and explanations after the deterministic gate has done its job.
Related guides
Common Questions
Can cTrader Open API use FXMacroData?
Yes. Put FXMacroData in the execution service that prepares cTrader messages. The service should call FXMacroData REST, apply a macro policy, and send a cTrader order message only when the candidate passes the gate.
Should a cTrader integration use REST or MCP for FXMacroData?
Use REST for the production macro gate because it is deterministic and easy to test. Use MCP for analyst and assistant workflows such as blocked-order explanations, research notes, and replay analysis.
Does FXMacroData replace cTrader pricing or order execution?
No. cTrader remains the broker-side account, symbol, pricing, and order-message surface. FXMacroData adds macro context around the execution decision.
Sources and References
- cTrader Open API documentation
- cTrader Open API application registration
- cTrader Open API app and account authentication
- cTrader Open API proxies and endpoints
- cTrader Open API connection guide
- cTrader Open API message reference
- Spotware cTrader Open API product page
- FXMacroData production OpenAPI schema
- FXMacroData MCP Server documentation