trademagic guides
How to build an MT5 Expert Advisor backed by a signals API
An Expert Advisor does not need to invent trade ideas. The strongest pattern is an EA that consumes certified external signals over HTTPS and owns exactly two jobs: sizing and execution.
Start with a free trial. No credit card required.

The architecture in one paragraph
Your EA runs a timer, polls the FX Insights API for fresh signals, and maps each one to an order at your broker with position sizing derived from the signal's stop distance. The models, the data, and the certification live on our side; the account, the risk, and the execution stay entirely on yours.
Step 1: allowlist the API in MetaTrader
MQL5's WebRequest refuses every URL by default. In MetaTrader 5 open Tools, then Options, then the Expert Advisors tab, tick "Allow WebRequest for listed URL" and add https://trademagic.ai. Skipping this is the number one reason EA HTTP calls fail with error -1.
Step 2: generate a read-only key
Sign up, start your trial, and generate a key from the API page of your dashboard. The key is shown once, is read-only by design, and can be rotated in one click. Keep it in an input parameter or the terminal's global variables, never hard-coded into shared source.
Step 3: poll and parse
// FX Insights consumer EA (skeleton)
input string InpApiKey = "tp_live_YOUR_KEY";
const string BASE = "https://trademagic.ai/api/ext/v1";
int OnInit() {
EventSetTimer(60); // poll once a minute
return INIT_SUCCEEDED;
}
void OnTimer() {
string headers = "Authorization: Bearer " + InpApiKey + "\r\n";
char body[], result[];
string result_headers;
int status = WebRequest("GET", BASE + "/signals", headers, 5000,
body, result, result_headers);
if (status != 200) {
Print("signals request failed: ", status); // -1 = URL not allowlisted
return;
}
string json = CharArrayToString(result);
// Parse with a JSON library (e.g. the community JAson.mqh), then for each
// fresh signal you have not acted on: compute lots from the SL distance
// and YOUR risk percent, and place the order with your own caps.
}Each signal carries pair, side, entry, sl, tp, rr, ev, and an eta window, with prices as strings to preserve FX precision. For production use the /signals/updates cursor endpoint instead of the snapshot: it hands you only new signals and status changes, which makes duplicate protection trivial.
Step 4: sizing is your edge management
Convert the distance between entry and stop into lots so each trade risks a fixed fraction of equity, respect a maximum open-position count, and take the signals systematically. The models' certified statistics assume every signal is executed; an EA is precisely how you match that assumption without sitting at the screen.
Start with a free trial
Create an account and your API key is minutes away.
Frequently asked questions
Does this work with MT4 as well?
Yes. MT4's WebRequest is more limited but supports the same pattern. MT5 is the better target for new builds: richer JSON handling through community libraries, netting and hedging account support, and an active toolchain.
Does trademagic place the trades?
Never. The API key is read-only and can only fetch signals. Your EA decides sizing and sends orders to your broker; we have no access to your account or funds.
Is polling fast enough for an EA?
Yes. Signals are positioning and macro driven and play out over hours, not milliseconds. A 30 to 60 second timer is comfortably inside the useful window, and the API allows 60 requests per minute.
Can ChatGPT write the EA for me?
It is genuinely good at it. Give it the API description from this page and ask for an MQL5 EA skeleton with your sizing rules; you review the risk logic, it writes the boilerplate.
Start with a free trial
Create an account and your API key is minutes away.